mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
update styletron example to support multiple stylesheets (#763)
This commit is contained in:
parent
23cddda9cf
commit
5ef34c6dd8
|
@ -5,8 +5,8 @@ export default class MyDocument extends Document {
|
||||||
static getInitialProps ({ renderPage }) {
|
static getInitialProps ({ renderPage }) {
|
||||||
const page = renderPage()
|
const page = renderPage()
|
||||||
const styletron = flush()
|
const styletron = flush()
|
||||||
const css = styletron ? styletron.getCss() : null
|
const stylesheets = styletron ? styletron.getStylesheets() : []
|
||||||
return { ...page, css }
|
return { ...page, stylesheets }
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
@ -14,7 +14,14 @@ export default class MyDocument extends Document {
|
||||||
<html>
|
<html>
|
||||||
<Head>
|
<Head>
|
||||||
<title>My page</title>
|
<title>My page</title>
|
||||||
<style className='_styletron_hydrate_' dangerouslySetInnerHTML={{ __html: this.props.css }} />
|
{this.props.stylesheets.map((sheet, i) => (
|
||||||
|
<style
|
||||||
|
className="_styletron_hydrate_"
|
||||||
|
dangerouslySetInnerHTML={{ __html: sheet.css }}
|
||||||
|
media={sheet.media || ''}
|
||||||
|
key={i}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</Head>
|
</Head>
|
||||||
<body>
|
<body>
|
||||||
<Main />
|
<Main />
|
||||||
|
|
Loading…
Reference in a new issue