-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-ssr.js
40 lines (32 loc) · 1.1 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
import React from 'react'
import { ThemeProvider } from 'styled-components'
import { HelmetProvider } from 'react-helmet-async'
import theme from './static/styles/theme'
import Layout from './src/components/Layout'
import { GlobalStyle } from './src/components/GlobalStyles'
import RegFont from './static/fonts/fortika-regular-webfont.woff2';
export const wrapRootElement = ({ element }) => {
const helmetContext = {}
return (
<HelmetProvider context={helmetContext}>
<ThemeProvider theme={theme}>
<GlobalStyle />
{element}
</ThemeProvider>
</HelmetProvider>
)
}
// Pass all props (hence the ...props) to the layout component so it has access to things like pageContext or location
export const wrapPageElement = ({ element, props }) => (
<Layout {...props}>{element}</Layout>
)
export const onRenderBody = (
{ setHeadComponents, setHtmlAttributes, setBodyAttributes },
pluginOptions
) => {
let headComponents = [];
headComponents.push(
<link rel="preload" href={RegFont} as="font" type="font/woff2" crossOrigin=""></link>
);
setHeadComponents(headComponents);
}