Permalink
Newer
100644
124 lines (116 sloc)
3.95 KB
1
// @flow
2
3
import React from 'react';
4
import Document, { Head, Main, NextScript } from 'next/document';
6
import getContext from 'docs/src/modules/styles/getContext';
7
import config from 'docs/src/config';
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 name="twitter:image" content="https://material-ui-next.com/static/brand.png" />
51
{/* Facebook */}
52
<meta property="og:type" content="website" />
53
<meta property="og:title" content="Material-UI" />
54
<meta
55
property="og:description"
56
content="React Components that Implement Google's Material Design."
57
/>
63
{/* Global Site Tag (gtag.js) - Google Analytics */}
64
<script async src={`https://www.googletagmanager.com/gtag/js?id=${config.google.id}`} />
65
<script
66
// eslint-disable-next-line react/no-danger
67
dangerouslySetInnerHTML={{
68
__html: `
69
window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments)};
70
gtag('js', new Date());
71
`,
72
}}
73
/>
76
</body>
77
</html>
78
);
79
}
80
}
81
82
MyDocument.getInitialProps = ctx => {
83
// Resolution order
84
//
85
// On the server:
86
// 1. page.getInitialProps
87
// 2. document.getInitialProps
88
// 3. page.render
89
// 4. document.render
90
//
91
// On the server with error:
92
// 2. document.getInitialProps
93
// 3. page.render
94
// 4. document.render
95
//
96
// On the client
97
// 1. page.getInitialProps
98
// 3. page.render
99
105
106
let css = context.sheetsRegistry.toString();
107
if (process.env.NODE_ENV === 'production') {
108
css = cleanCSS.minify(css).styles;
109
}
110
114
styles: (
115
<style
116
id="jss-server-side"
117
// eslint-disable-next-line react/no-danger