forked from usecannon/cannon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdx-components.tsx
46 lines (45 loc) · 1.08 KB
/
mdx-components.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type { MDXComponents } from 'mdx/types';
import { Text, Code, Heading } from '@chakra-ui/react';
import { headingToId } from '@/helpers/markdown';
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
p: ({ ...props }) => <Text {...props} mt={4} />,
h1: ({ ...props }) => <Heading as="h1" {...props} mb={4} />,
h2: ({ ...props }) => (
<Heading
as="h2"
{...props}
mb={4}
pt={8}
fontSize={24}
id={headingToId(props)}
/>
),
h3: ({ ...props }) => (
<Heading
as="h3"
{...props}
mb={4}
pt={8}
fontSize={20}
id={headingToId(props)}
/>
),
code: ({ ...props }) => (
<Code colorScheme="blackAlpha" variant="solid" {...props} />
),
Alert: ({ ...props }) => (
<div
style={{
padding: 20,
backgroundColor: 'rgb(14 28 60)',
marginBottom: 20,
border: '1px solid rgb(13 20 38)',
}}
>
{props.children}
</div>
),
...components,
};
}