Permalink
Newer
100644
133 lines (125 sloc)
4.14 KB
1
// @flow
2
3
import React from 'react';
4
import Document, { Head, Main, NextScript } from 'next/document';
6
import JssProvider from 'react-jss/lib/JssProvider';
7
import getContext from 'docs/src/modules/styles/getContext';
8
import config from 'docs/src/config';
11
12
class MyDocument extends Document {
13
render() {
14
return (
15
<html lang="en" dir="ltr">
16
<Head>
17
<title>Material-UI</title>
18
<meta
19
name="description"
20
content="React Components that Implement Google's Material Design."
21
/>
22
<meta charSet="utf-8" />
23
{/* Use minimum-scale=1 to enable GPU rasterization */}
24
<meta
25
name="viewport"
26
content={
27
'user-scalable=0, initial-scale=1, ' +
28
'minimum-scale=1, width=device-width, height=device-height'
29
}
30
/>
31
{/*
32
manifest.json provides metadata used when your web app is added to the
33
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
34
*/}
35
<link rel="manifest" href="/static/manifest.json" />
36
{/* PWA primary color */}
37
<meta name="theme-color" content={this.props.stylesContext.theme.palette.primary[500]} />
38
<link
39
rel="stylesheet"
40
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"
41
/>
45
<meta name="twitter:site" content="@MaterialUI" />
46
<meta name="twitter:title" content="Material-UI" />
47
<meta
48
name="twitter:description"
49
content="React Components that Implement Google's Material Design."
51
<meta
52
name="twitter:image"
53
content="https://material-ui-1dab0.firebaseapp.com/static/brand.png"
54
/>
55
{/* Facebook */}
56
<meta property="og:type" content="website" />
57
<meta property="og:title" content="Material-UI" />
58
<meta
59
property="og:description"
60
content="React Components that Implement Google's Material Design."
61
/>
62
<meta
63
property="og:image"
64
content="https://material-ui-1dab0.firebaseapp.com/static/brand.png"
65
/>
70
{/* Global Site Tag (gtag.js) - Google Analytics */}
71
<script async src={`https://www.googletagmanager.com/gtag/js?id=${config.google.id}`} />
72
<script
73
// eslint-disable-next-line react/no-danger
74
dangerouslySetInnerHTML={{
75
__html: `
76
window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments)};
77
gtag('js', new Date());
78
`,
79
}}
80
/>
83
</body>
84
</html>
85
);
86
}
87
}
88
89
MyDocument.getInitialProps = ctx => {
90
// Resolution order
91
//
92
// On the server:
93
// 1. page.getInitialProps
94
// 2. document.getInitialProps
95
// 3. page.render
96
// 4. document.render
97
//
98
// On the server with error:
99
// 2. document.getInitialProps
100
// 3. page.render
101
// 4. document.render
102
//
103
// On the client
104
// 1. page.getInitialProps
105
// 3. page.render
106
109
const page = ctx.renderPage(Component => props => (
110
<JssProvider registry={context.sheetsRegistry} jss={context.jss}>
111
<Component {...props} />
112
</JssProvider>
113
));
114
115
let css = context.sheetsRegistry.toString();
116
if (process.env.NODE_ENV === 'production') {
117
css = cleanCSS.minify(css).styles;
118
}
119
123
styles: (
124
<style
125
id="jss-server-side"
126
// eslint-disable-next-line react/no-danger