2019-11-08 04:53:25 +01:00
|
|
|
const React = require('react');
|
2019-12-18 23:54:23 +01:00
|
|
|
const Layout = require('./src/components/Layout').default;
|
|
|
|
const NodeProvider = require('./src/components/NodeProvider').default;
|
2019-11-08 03:40:20 +01:00
|
|
|
|
2019-12-18 23:54:23 +01:00
|
|
|
/**
|
|
|
|
* Applies the node provider (static query of all documents)
|
|
|
|
* Ensures the chrome doesn't rerender every page load, which makes the sidebar reset its scroll.
|
|
|
|
*/
|
2019-11-08 04:53:25 +01:00
|
|
|
exports.wrapPageElement = ({ element, props }) => {
|
2019-12-18 23:54:23 +01:00
|
|
|
return (
|
|
|
|
<NodeProvider {...props}>
|
|
|
|
<Layout {...props}>
|
|
|
|
{element}
|
|
|
|
</Layout>
|
|
|
|
</NodeProvider>
|
|
|
|
);
|
2019-11-14 03:58:07 +01:00
|
|
|
};
|
|
|
|
|
2019-12-18 23:54:23 +01:00
|
|
|
exports.onRenderBody = ({ setPostBodyComponents, setHeadComponents, pathname }) => {
|
2019-11-15 04:04:03 +01:00
|
|
|
// Rules that cannot be touched by purgecss because they come in from client side rendering
|
2023-04-13 06:54:23 +02:00
|
|
|
setHeadComponents([
|
2019-11-15 04:07:27 +01:00
|
|
|
<style key='prism-css' type="text/css" dangerouslySetInnerHTML={{
|
2019-11-15 04:04:03 +01:00
|
|
|
__html: `
|
|
|
|
:not(pre) > code[class*="language-"] {
|
|
|
|
background: #f5f6f8;
|
|
|
|
color: #5d6778;
|
|
|
|
text-shadow: none;
|
|
|
|
}
|
|
|
|
.algolia-autocomplete {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
.gatsby-highlight {
|
|
|
|
margin: 2rem 0;
|
|
|
|
}
|
|
|
|
`
|
|
|
|
}} />
|
|
|
|
]);
|
2019-11-14 03:58:07 +01:00
|
|
|
setPostBodyComponents([
|
2019-11-14 23:40:23 +01:00
|
|
|
process.env.NODE_ENV === 'production' &&
|
|
|
|
<script key='ga' dangerouslySetInnerHTML={{
|
2019-11-14 03:58:07 +01:00
|
|
|
__html: `
|
|
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
|
|
|
|
|
|
ga('create', 'UA-84547-17', 'auto', {'allowLinker': true});
|
|
|
|
ga('require', 'linker');
|
|
|
|
ga('linker:autoLink', [
|
|
|
|
'www.silverstripe.com',
|
|
|
|
'www.silverstripe.org',
|
|
|
|
'addons.silverstripe.org',
|
|
|
|
'api.silverstripe.org',
|
|
|
|
'docs.silverstripe.org',
|
|
|
|
'userhelp.silverstripe.org',
|
|
|
|
'demo.silverstripe.org'
|
|
|
|
]);
|
|
|
|
ga('send', 'pageview')
|
|
|
|
`
|
|
|
|
}} />
|
|
|
|
])
|
2019-11-08 04:53:25 +01:00
|
|
|
};
|