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