2016-12-23 13:01:24 +00:00
|
|
|
import Document, { Head, Main, NextScript } from 'next/document'
|
|
|
|
import { flush } from '../styletron'
|
|
|
|
|
|
|
|
export default class MyDocument extends Document {
|
|
|
|
static getInitialProps ({ renderPage }) {
|
|
|
|
const page = renderPage()
|
|
|
|
const styletron = flush()
|
2017-01-13 23:49:35 +00:00
|
|
|
const stylesheets = styletron ? styletron.getStylesheets() : []
|
|
|
|
return { ...page, stylesheets }
|
2016-12-23 13:01:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<html>
|
|
|
|
<Head>
|
2017-01-13 23:49:35 +00:00
|
|
|
{this.props.stylesheets.map((sheet, i) => (
|
|
|
|
<style
|
2017-01-14 15:30:39 +00:00
|
|
|
className='_styletron_hydrate_'
|
2017-01-13 23:49:35 +00:00
|
|
|
dangerouslySetInnerHTML={{ __html: sheet.css }}
|
|
|
|
media={sheet.media || ''}
|
|
|
|
key={i}
|
|
|
|
/>
|
|
|
|
))}
|
2016-12-23 13:01:24 +00:00
|
|
|
</Head>
|
|
|
|
<body>
|
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|