-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathstatic.config.js
183 lines (171 loc) · 5.79 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import fs from 'fs-extra';
import path from 'path';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import {ServerStyleSheet} from 'styled-components';
import React from 'react';
const REACT_STATIC_PATHS = {
src: 'src',
dist: 'dist',
devDist: 'dist',
public: 'public',
};
const ARAGON_UI_ASSETS = path.dirname(require.resolve('@aragon/ui'));
export default {
siteRoot: process.env.SITE_ROOT || '',
getSiteData: () => ({
title: 'Aragon One',
}),
getRoutes: () => [
{
path: '/',
component: 'src/pages/Home',
getData: () => ({title: ''}),
},
{
path: '/jobs',
component: 'src/pages/Jobs',
getData: () => ({title: ''}),
},
{
path: '/privacy-policy',
component: 'src/pages/PrivacyPolicy',
getData: () => ({title: ''}),
},
{
path: '/privacy-notice',
component: 'src/pages/PrivacyNotice',
getData: () => ({title: ''}),
},
],
paths: REACT_STATIC_PATHS,
webpack: (conf, {defaultLoaders}) => {
conf.resolve = Object.assign({}, conf.resolve || {}, {
// Needed when @aragon/ui is linked (development)
modules: ((conf.resolve && conf.resolve.modules) || []).concat([
path.join(__dirname, 'node_modules'),
path.join(__dirname, REACT_STATIC_PATHS.dist),
]),
});
// Copy the Aragon UI assets to dist/aragon-ui. CopyWebpackPlugin is aware
// of webpack-dev-server so there is no need to add this directory to the
// devServer configuration.
conf.plugins = (conf.plugins || []).concat([
new CopyWebpackPlugin([
{
from: ARAGON_UI_ASSETS,
to: path.resolve(
path.join(__dirname, REACT_STATIC_PATHS.dist, 'aragon-ui')
),
},
]),
]);
const fileLoader = defaultLoaders.fileLoader;
fileLoader.query.name = 'static/[hash:8]-[name].[ext]';
conf.module.rules = [
{
oneOf: [defaultLoaders.jsLoader, defaultLoaders.cssLoader, fileLoader],
},
];
conf.plugins.push(new ExtractTextPlugin('app.css'));
return conf;
},
renderToHtml: (render, Comp, meta) => {
const sheet = new ServerStyleSheet();
const html = render(sheet.collectStyles(<Comp />));
meta.styleTags = sheet.getStyleElement();
return html;
},
Document: class CustomHtml extends React.Component {
analyticsCode() {
if (process.env.NODE_ENV !== 'production') return '';
return `
var Countly = Countly || {};
Countly.q = Countly.q || [];
//provide countly initialization parameters
Countly.app_key = '00e285914b3ca2424a78bd6b7987362465022466';
Countly.url = 'https://analytics.aragon.org/';
Countly.inactivity_time = 10;
Countly.q.push(['track_sessions']);
Countly.q.push(['track_pageview']);
Countly.q.push(['track_clicks']);
Countly.q.push(['track_errors']);
(function() {
var cly = document.createElement('script'); cly.type = 'text/javascript';
cly.async = true;
cly.src = 'https://analytics.aragon.org/sdk/web/countly.min.js';
cly.onload = function(){Countly.init()};
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);
})();
`;
}
render() {
const {
Html,
Head,
Body,
siteData: {title: siteTitle},
children,
renderMeta,
routeInfo: {allProps: {title} = {}} = {},
} = this.props;
return (
<Html>
<Head>
<meta charSet="UTF-8" />
<title>{title || siteTitle}</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
<link rel="icon" href="/favicon.png" />
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"
crossOrigin="anonymous"
/>
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@AragonOneTeam" />
<meta name="twitter:creator" content="@AragonOneTeam" />
<meta
name="twitter:description"
content="We believe and fight for freedom"
/>
<meta name="twitter:title" content="Aragon One" />
<meta
name="twitter:image"
content="https://raw.githubusercontent.com/aragonone/website/master/public/twitter-card-icon.png"
/>
<meta property="og:title" content="Aragon One" />
<meta
property="og:description"
content="We believe and fight for freedom"
/>
<meta property="og:url" content="https://aragon.one/" />
<meta property="og:site_name" content="Aragon One" />
<meta
property="og:image"
content="https://raw.githubusercontent.com/aragonone/website/master/public/twitter-card-icon.png"
/>
<meta
property="og:image:secure_url"
content="https://raw.githubusercontent.com/aragonone/website/master/public/twitter-card-icon.png"
/>
<meta property="og:image:width" content="300" />
<meta property="og:image:height" content="300" />
<meta
name="description"
content="We believe and fight for freedom"
/>
{renderMeta.styleTags}
</Head>
<Body>
{children}
<script dangerouslySetInnerHTML={{__html: this.analyticsCode()}} />
</Body>
</Html>
);
}
},
};