-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstatic.config.js
executable file
·101 lines (98 loc) · 2.62 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import React from 'react'
import fetchContent from './src/utils/fetch-content'
async function getRoutes() {
const issues = await fetchContent()
const latestIssue = issues[0]
const getIssueRoute = (issue) => ({
template: 'src/containers/IssuePage',
getData: () => ({
issue,
isLatest: issue.number === latestIssue.number,
}),
})
return [
{
path: '/',
template: 'src/containers/HomePage',
getData: () => ({
issues,
}),
},
{
path: '/issues',
template: 'src/containers/IssueListPage',
getData: () => ({
issues,
}),
children: issues.map((issue) => ({
...getIssueRoute(issue),
path: `/${issue.number}`,
})),
},
{ path: 'check-email', template: 'src/containers/CheckEmailPage' },
{
path: 'email-confirmed',
template: 'src/containers/EmailConfirmedPage',
},
{
path: 'existing-contact',
template: 'src/containers/ExistingContactPage',
},
{
path: '404',
template: 'src/containers/404',
},
{ path: '/latest', ...getIssueRoute(latestIssue) },
]
}
export default {
plugins: [
'react-static-plugin-styled-components',
'react-static-plugin-reach-router',
],
getSiteData: () => ({
title: 'Best of JavaScript Weekly',
}),
getRoutes: async () => {
try {
return await getRoutes()
} catch (error) {
console.error('Error while building the routes!', error.message)
// Don't try to display the stacktrace here, it will cause a strange error
process.exit(1) // throwing an error does not stop the building process
}
},
Document: ({ Html, Head, Body, children }) => {
const ga = `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-44563970-5');
`
return (
<Html>
<Head>
<meta charSet="UTF-8" />
<title>Best of JS Weekly</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
property="og:image"
content="https://bestofjs.org/images/logo.png"
/>
<link
href="https://fonts.googleapis.com/css?family=Space+Mono:400,400i|Roboto+Slab:300,400,700"
rel="stylesheet"
/>
</Head>
<Body>
{children}
<script
async
src="https://www.googletagmanager.com/gtag/js?id=UA-44563970-5"
/>
<script dangerouslySetInnerHTML={{ __html: ga }} />
</Body>
</Html>
)
},
}