-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstatic.config.js
77 lines (75 loc) · 2.18 KB
/
static.config.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Libs
import React, {Component} from 'react';
import {ServerStyleSheet} from 'styled-components';
export default {
// Site Props
getSiteProps: () => ({
title: 'React Static',
}),
// Site Routes
getRoutes: () => [
{
path: '/',
component: 'src/containers/Home',
},
{
path: '/features',
component: 'src/containers/Features',
},
{
path: '/about',
component: 'src/containers/About',
},
{
is404: true,
component: 'src/containers/404',
},
],
// Render
renderToHtml: (render, Comp, meta) => {
const sheet = new ServerStyleSheet();
const html = render(sheet.collectStyles(<Comp />));
meta.styleTags = sheet.getStyleElement();
return html;
},
Document: class CustomHtml extends Component {
render() {
const {Html, Head, Body, children, renderMeta} = this.props;
return (
<Html>
<Head>
<title>Manta App</title>
<meta charSet="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
crossOrigin="anonymous"
/>
<link
href="https://fonts.googleapis.com/css?family=Titillium+Web:300,600&subset=latin-ext"
rel="stylesheet"
type="text/css"
/>
<script dangerouslySetInnerHTML={createGTMScript()} />
</Head>
<Body>{children}</Body>
</Html>
);
}
},
};
function createGTMScript() {
const gtmScript = `
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5JF3TD7');
`;
return {__html: gtmScript};
}