mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
make sure to flush styles and head (#459)
This commit is contained in:
parent
4faa281f23
commit
fe962b12de
|
@ -6,12 +6,18 @@ import flush from 'styled-jsx/server'
|
|||
export default class Document extends Component {
|
||||
static getInitialProps ({ renderPage }) {
|
||||
let head
|
||||
const { html, css, ids } = renderStatic(() => {
|
||||
const page = renderPage()
|
||||
head = page.head
|
||||
return page.html
|
||||
})
|
||||
const styles = flush()
|
||||
let rendered
|
||||
let styles
|
||||
try {
|
||||
rendered = renderStatic(() => {
|
||||
const page = renderPage()
|
||||
head = page.head
|
||||
return page.html
|
||||
})
|
||||
} finally {
|
||||
styles = flush()
|
||||
}
|
||||
const { html, css, ids } = rendered
|
||||
const nextCSS = { css, ids, styles }
|
||||
return { html, head, nextCSS }
|
||||
}
|
||||
|
|
|
@ -62,8 +62,15 @@ async function doRender (req, res, pathname, query, {
|
|||
router: new Router(pathname, query)
|
||||
})
|
||||
|
||||
const html = (staticMarkup ? renderToStaticMarkup : renderToString)(app)
|
||||
const head = Head.rewind() || defaultHead()
|
||||
const render = staticMarkup ? renderToStaticMarkup : renderToString
|
||||
|
||||
let html
|
||||
let head
|
||||
try {
|
||||
html = render(app)
|
||||
} finally {
|
||||
head = Head.rewind() || defaultHead()
|
||||
}
|
||||
return { html, head }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue