-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrap-root-element.js
56 lines (54 loc) · 1.51 KB
/
wrap-root-element.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
47
48
49
50
51
52
53
54
55
56
/* eslint-disable react/display-name */
import React from 'react'
import { MDXProvider } from '@mdx-js/react'
import { preToCodeBlock } from 'mdx-utils'
import { Helmet } from 'react-helmet'
import { Code } from './src/components/Code'
import Layout from './src/components/Layout'
// components is its own object outside of render so that the references to
// components are stable
const components = {
pre: (preProps) => {
const props = preToCodeBlock(preProps)
// if there's a codeString and some props, we passed the test
if (props) {
return <Code {...props} />
}
// it's possible to have a pre without a code in it
return <pre {...preProps} />
},
}
export const wrapRootElement = ({ element }) => (
<>
<Helmet>
<link
rel="apple-touch-icon"
sizes="180x180"
href="/favicons/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/favicons/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/favicons/favicon-16x16.png"
/>
<link rel="manifest" href="/favicons/site.webmanifest" />
<link
rel="mask-icon"
href="/favicons/safari-pinned-tab.svg"
color="#3b2b1e"
/>
<meta name="msapplication-TileColor" content="#ffffff" />
<meta name="theme-color" content="#ffffff" />
</Helmet>
<Layout>
<MDXProvider components={components}>{element}</MDXProvider>
</Layout>
</>
)