-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroot-wrapper.js
More file actions
35 lines (31 loc) · 1 KB
/
root-wrapper.js
File metadata and controls
35 lines (31 loc) · 1 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
import React from "react"
import { MDXProvider } from "@mdx-js/react"
import { ThemeProvider } from "react-jss"
import theme from "./src/styles/theme"
import { P, Code, CodeWrapper, A } from "./src/styles/mdx"
const components = {
wrapper: ({ children }) => <>{children}</>,
p: props => <P {...props} />,
a: props => <A {...props} />,
pre: ({ children: { props } }) => {
if (props.mdxType === "code") {
return (
<div>
<Code
codeString={props.children.trim()}
language={
props.className &&
props.className.replace("language-", "")
}
{...props}
/>
</div>
)
}
},
}
export const wrapRootElement = ({ element }) => (
<ThemeProvider theme={theme}>
<MDXProvider components={components}>{element}</MDXProvider>
</ThemeProvider>
)