2017-05-25 16:36:21 +00:00
|
|
|
import React from 'react'
|
|
|
|
import Document, { Head, Main, NextScript } from 'next/document'
|
2017-07-24 04:39:36 +00:00
|
|
|
import { getContext, setContext } from '../styles/context'
|
2017-05-25 16:36:21 +00:00
|
|
|
|
|
|
|
export default class MyDocument extends Document {
|
|
|
|
static async getInitialProps (ctx) {
|
2017-07-24 04:39:36 +00:00
|
|
|
// Reset the context for handling a new request.
|
|
|
|
setContext()
|
2017-05-25 16:36:21 +00:00
|
|
|
const page = ctx.renderPage()
|
2017-07-24 04:39:36 +00:00
|
|
|
// Get the context with the collected side effects.
|
|
|
|
const context = getContext()
|
2017-05-25 16:36:21 +00:00
|
|
|
return {
|
|
|
|
...page,
|
2017-07-24 04:39:36 +00:00
|
|
|
styles: <style id='jss-server-side' dangerouslySetInnerHTML={{ __html: context.sheetsRegistry.toString() }} />
|
2017-05-25 16:36:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2017-07-24 04:39:36 +00:00
|
|
|
const context = getContext()
|
2017-05-25 16:36:21 +00:00
|
|
|
return (
|
|
|
|
<html lang='en'>
|
|
|
|
<Head>
|
|
|
|
<title>My page</title>
|
|
|
|
<meta charSet='utf-8' />
|
|
|
|
{/* Use minimum-scale=1 to enable GPU rasterization */}
|
|
|
|
<meta
|
|
|
|
name='viewport'
|
|
|
|
content={
|
|
|
|
'user-scalable=0, initial-scale=1, maximum-scale=1, ' +
|
|
|
|
'minimum-scale=1, width=device-width, height=device-height'
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
{/* PWA primary color */}
|
2017-07-24 04:39:36 +00:00
|
|
|
<meta name='theme-color' content={context.theme.palette.primary[500]} />
|
2017-05-25 16:36:21 +00:00
|
|
|
<link
|
|
|
|
rel='stylesheet'
|
|
|
|
href='https://fonts.googleapis.com/css?family=Roboto:300,400,500'
|
|
|
|
/>
|
|
|
|
</Head>
|
|
|
|
<body>
|
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|