2017-06-29 05:44:48 +00:00
|
|
|
import Document, { Head, Main, NextScript } from 'next/document'
|
2017-07-06 05:44:46 +00:00
|
|
|
import { extractCritical } from 'emotion/server'
|
2017-06-29 05:44:48 +00:00
|
|
|
|
|
|
|
export default class MyDocument extends Document {
|
|
|
|
static getInitialProps ({ renderPage }) {
|
|
|
|
const page = renderPage()
|
2017-07-06 05:44:46 +00:00
|
|
|
const styles = extractCritical(page.html)
|
2017-06-29 05:44:48 +00:00
|
|
|
return { ...page, ...styles }
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor (props) {
|
|
|
|
super(props)
|
|
|
|
const { __NEXT_DATA__, ids } = props
|
|
|
|
if (ids) {
|
|
|
|
__NEXT_DATA__.ids = this.props.ids
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<html>
|
|
|
|
<Head>
|
|
|
|
<title>With Emotion</title>
|
|
|
|
<style dangerouslySetInnerHTML={{ __html: this.props.css }} />
|
|
|
|
</Head>
|
|
|
|
<body>
|
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|