forked from freeCodeCamp/guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-ssr.js
30 lines (27 loc) · 833 Bytes
/
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
import React from 'react';
import { renderToString } from 'react-dom/server';
import NavigationContextProvider from './src/contexts/NavigationContext';
export const replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) =>
replaceBodyHTMLString(
renderToString(
<NavigationContextProvider>{bodyComponent}</NavigationContextProvider>
)
);
export const onRenderBody = ({ setHeadComponents }) => {
setHeadComponents([
<script
async={true}
src='https://www.googletagmanager.com/gtag/js?id=AW-795617839'
/>,
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-795617839');
`
}}
/>
]);
};