-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgatsby-ssr.js
44 lines (36 loc) · 1.2 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
/**
* Copyright Zendesk, Inc.
*
* Use of this source code is governed under the Apache License, Version 2.0
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/
import React from 'react';
import { Provider, Layout } from './src/components';
import __html from '!!raw-loader!./utils/color-scheme.js';
export const wrapRootElement = ({ props, element }) => <Provider {...props}>{element}</Provider>;
export const wrapPageElement = ({ props, element }) => <Layout {...props}>{element}</Layout>;
export const onRenderBody = ({
setHtmlAttributes,
setHeadComponents,
setPreBodyComponents,
setPostBodyComponents
}) => {
setHtmlAttributes({ lang: 'en' });
const version = 2;
setHeadComponents([
<link
key="docsearch-css"
rel="stylesheet"
href={`https://cdn.jsdelivr.net/npm/docsearch.js@${version}/dist/cdn/docsearch.min.css`}
/>
]);
/* eslint-disable-next-line react/no-danger */
setPreBodyComponents([<script key="color-scheme-js" dangerouslySetInnerHTML={{ __html }} />]);
setPostBodyComponents([
<script
key="docsearch-js"
type="text/javascript"
src={`https://cdn.jsdelivr.net/npm/docsearch.js@${version}/dist/cdn/docsearch.min.js`}
/>
]);
};