2016-12-22 05:10:54 +00:00
|
|
|
import Document, { Head, Main, NextScript } from 'next/document'
|
2017-05-07 12:25:33 +00:00
|
|
|
import { ServerStyleSheet } from 'styled-components'
|
2016-12-22 05:10:54 +00:00
|
|
|
|
|
|
|
export default class MyDocument extends Document {
|
2017-09-14 12:17:18 +00:00
|
|
|
static getInitialProps ({ renderPage }) {
|
2017-05-07 12:25:33 +00:00
|
|
|
const sheet = new ServerStyleSheet()
|
2017-09-14 12:17:18 +00:00
|
|
|
const page = renderPage(App => props => sheet.collectStyles(<App {...props} />))
|
2017-05-07 12:25:33 +00:00
|
|
|
const styleTags = sheet.getStyleElement()
|
2017-09-14 12:17:18 +00:00
|
|
|
return { ...page, styleTags }
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2016-12-22 05:10:54 +00:00
|
|
|
return (
|
|
|
|
<html>
|
|
|
|
<Head>
|
|
|
|
<title>My page</title>
|
2017-09-14 12:17:18 +00:00
|
|
|
{this.props.styleTags}
|
2016-12-22 05:10:54 +00:00
|
|
|
</Head>
|
|
|
|
<body>
|
2017-09-14 12:17:18 +00:00
|
|
|
<Main />
|
2016-12-22 05:10:54 +00:00
|
|
|
<NextScript />
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|