-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-ssr.js
47 lines (41 loc) · 1.22 KB
/
gatsby-ssr.js
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 React from "react"
import { createGlobalStyle, ThemeProvider } from "styled-components"
import { MDXProvider } from "@mdx-js/react"
import { preToCodeBlock } from "mdx-utils"
import Theme from "./src/themes/theme"
import { Table, Code } from "./src/components"
import "./language-tabs.css"
const GlobalStyles = createGlobalStyle`
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body, html {
font-family: ${props => props.theme.fonts.main};
height: 100%;
color:${props => props.theme.colors.black};
background-color: ${props => props.theme.colors.greyLight1};
}
`
const components = {
table: Table,
pre: preProps => {
const props = preToCodeBlock(preProps)
// check if there is codeString and props
if (props) {
return <Code {...props} />
}
// return a pre without a code in it
return <pre {...preProps} />
},
wrapper: ({ children }) => <>{children}</>,
}
export const wrapRootElement = ({ element }) => (
<MDXProvider components={components}>
<ThemeProvider theme={Theme}>
<GlobalStyles />
{element}
</ThemeProvider>
</MDXProvider>
)