-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathroot-wrapper.js
More file actions
83 lines (81 loc) · 2.08 KB
/
root-wrapper.js
File metadata and controls
83 lines (81 loc) · 2.08 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { MDXProvider } from '@mdx-js/react';
import React from 'react';
import { Code } from './src/components/code';
const components = {
h2: ({ children, style, ...rest }) => (
<h2 {...rest} style={{ marginTop: 32, ...style }}>
{children}
</h2>
),
h3: ({ children, style, ...rest }) => (
<h3 {...rest} style={{ marginTop: 32, ...style }}>
{children}
</h3>
),
ul: ({ children, style, ...rest }) => (
<ul {...rest} style={{ marginLeft: 24, ...style }}>
{children}
</ul>
),
ol: ({ children, style, ...rest }) => (
<ol {...rest} style={{ marginLeft: 24, ...style }}>
{children}
</ol>
),
li: ({ children, style, ...rest }) => (
<li {...rest} style={{ lineHeight: '150%', ...style }}>
{children}
</li>
),
'p.inlineCode': (props) => (
<code
style={{
backgroundColor: '#777',
padding: '2px 4px',
borderRadius: 4,
color: 'white',
}}
{...props}
/>
),
iframe: ({ style, ...props }) => (
<iframe style={{ marginBottom: 48, ...style }} {...props} />
),
a: ({ children, style, ...rest }) => (
<a
{...rest}
style={{ ...style, display: 'inline-flex', alignItems: 'center' }}
>
{children}
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
style={{ marginLeft: 4, height: 20, width: 20 }}
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.5}
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
/>
</svg>
</a>
),
pre: ({ children: { props } }) => {
if (props.mdxType === 'code') {
return (
<Code
codeString={props.children.trim()}
language={props.className && props.className.replace('language-', '')}
{...props}
/>
);
}
},
};
export const wrapRootElement = ({ element }) => (
<MDXProvider components={components}>{element}</MDXProvider>
);