Skip to content
Permalink
04f6d4b7a7
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
121 lines (113 sloc) 3.67 KB
// @flow
import React from 'react';
import Document, { Head, Main, NextScript } from 'next/document';
import getContext from 'docs/src/modules/styles/getContext';
import JssProvider from 'react-jss/lib/JssProvider';
import CleanCSS from 'clean-css';
const cleanCSS = new CleanCSS();
class MyDocument extends Document {
render() {
return (
<html lang="en" dir="ltr">
<Head>
<title>Material-UI</title>
<meta
name="description"
content="React Components that Implement Google's Material Design."
/>
<meta charSet="utf-8" />
{/* Use minimum-scale=1 to enable GPU rasterization */}
<meta
name="viewport"
content={
'user-scalable=0, initial-scale=1, ' +
'minimum-scale=1, width=device-width, height=device-height'
}
/>
{/*
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
*/}
<link rel="manifest" href="/static/manifest.json" />
{/* PWA primary color */}
<meta name="theme-color" content={this.props.stylesContext.theme.palette.primary[500]} />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"
/>
<style id="insertion-point-jss" />
{/* Twitter */}
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@MaterialUI" />
<meta name="twitter:title" content="Material-UI" />
<meta
name="twitter:description"
content="React Components that Implement Google's Material Design."
/>
<meta
name="twitter:image"
content="https://material-ui-1dab0.firebaseapp.com/static/brand.png"
/>
{/* Facebook */}
<meta property="og:type" content="website" />
<meta property="og:title" content="Material-UI" />
<meta
property="og:description"
content="React Components that Implement Google's Material Design."
/>
<meta
property="og:image"
content="https://material-ui-1dab0.firebaseapp.com/static/brand.png"
/>
<link rel="shortcut icon" href="/static/favicon.ico" />
</Head>
<body>
<Main />
<NextScript />
<script src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js" async defer />
</body>
</html>
);
}
}
MyDocument.getInitialProps = ctx => {
// Resolution order
//
// On the server:
// 1. page.getInitialProps
// 2. document.getInitialProps
// 3. page.render
// 4. document.render
//
// On the server with error:
// 2. document.getInitialProps
// 3. page.render
// 4. document.render
//
// On the client
// 1. page.getInitialProps
// 3. page.render
// Get the context to collected side effects.
const context = getContext();
const page = ctx.renderPage(Component => props => (
<JssProvider registry={context.sheetsRegistry} jss={context.jss}>
<Component {...props} />
</JssProvider>
));
let css = context.sheetsRegistry.toString();
if (process.env.NODE_ENV === 'production') {
css = cleanCSS.minify(css).styles;
}
return {
...page,
stylesContext: context,
styles: (
<style
id="jss-server-side"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: css }}
/>
),
};
};
export default MyDocument;