2018-08-23 16:29:26 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
|
2018-09-30 11:37:19 +01:00
|
|
|
import headComponents from './src/head';
|
2018-08-23 16:29:26 +01:00
|
|
|
import { createStore } from './src/redux/createStore';
|
|
|
|
|
2019-02-28 15:44:35 +00:00
|
|
|
import layoutSelector from './utils/gatsby/layoutSelector';
|
2018-10-04 14:47:55 +01:00
|
|
|
|
2018-08-23 16:29:26 +01:00
|
|
|
const store = createStore();
|
|
|
|
|
|
|
|
export const wrapRootElement = ({ element }) => {
|
2019-02-20 15:41:33 +03:00
|
|
|
return <Provider store={store}>{element}</Provider>;
|
2018-08-23 16:29:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
wrapRootElement.propTypes = {
|
|
|
|
element: PropTypes.any
|
|
|
|
};
|
2018-09-30 11:37:19 +01:00
|
|
|
|
2019-02-28 15:44:35 +00:00
|
|
|
export const wrapPageElement = layoutSelector;
|
|
|
|
|
2018-09-30 11:37:19 +01:00
|
|
|
export const onRenderBody = ({ setHeadComponents, setPostBodyComponents }) => {
|
|
|
|
setHeadComponents([...headComponents]);
|
2018-11-29 12:12:15 +00:00
|
|
|
setPostBodyComponents(
|
|
|
|
[
|
|
|
|
<script
|
|
|
|
async={true}
|
|
|
|
key='gtag-script'
|
|
|
|
src='https://www.googletagmanager.com/gtag/js?id=AW-795617839'
|
|
|
|
/>,
|
|
|
|
<script
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: `
|
2018-09-30 11:37:19 +01:00
|
|
|
window.dataLayer = window.dataLayer || [];
|
|
|
|
function gtag(){dataLayer.push(arguments);}
|
|
|
|
gtag('js', new Date());
|
|
|
|
gtag('config', 'AW-795617839');
|
|
|
|
`
|
2018-11-29 12:12:15 +00:00
|
|
|
}}
|
|
|
|
key='gtag-dataLayer'
|
|
|
|
/>
|
|
|
|
].filter(Boolean)
|
|
|
|
);
|
2018-09-30 11:37:19 +01:00
|
|
|
};
|