Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
fe962b12
Commit
fe962b12
authored
Dec 21, 2016
by
Naoyuki Kanezawa
Committed by
Guillermo Rauch
Dec 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make sure to flush styles and head (#459)
parent
4faa281f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
document.js
server/document.js
+12
-6
render.js
server/render.js
+9
-2
No files found.
server/document.js
View file @
fe962b12
...
@@ -6,12 +6,18 @@ import flush from 'styled-jsx/server'
...
@@ -6,12 +6,18 @@ import flush from 'styled-jsx/server'
export
default
class
Document
extends
Component
{
export
default
class
Document
extends
Component
{
static
getInitialProps
({
renderPage
})
{
static
getInitialProps
({
renderPage
})
{
let
head
let
head
const
{
html
,
css
,
ids
}
=
renderStatic
(()
=>
{
let
rendered
const
page
=
renderPage
()
let
styles
head
=
page
.
head
try
{
return
page
.
html
rendered
=
renderStatic
(()
=>
{
})
const
page
=
renderPage
()
const
styles
=
flush
()
head
=
page
.
head
return
page
.
html
})
}
finally
{
styles
=
flush
()
}
const
{
html
,
css
,
ids
}
=
rendered
const
nextCSS
=
{
css
,
ids
,
styles
}
const
nextCSS
=
{
css
,
ids
,
styles
}
return
{
html
,
head
,
nextCSS
}
return
{
html
,
head
,
nextCSS
}
}
}
...
...
server/render.js
View file @
fe962b12
...
@@ -62,8 +62,15 @@ async function doRender (req, res, pathname, query, {
...
@@ -62,8 +62,15 @@ async function doRender (req, res, pathname, query, {
router
:
new
Router
(
pathname
,
query
)
router
:
new
Router
(
pathname
,
query
)
})
})
const
html
=
(
staticMarkup
?
renderToStaticMarkup
:
renderToString
)(
app
)
const
render
=
staticMarkup
?
renderToStaticMarkup
:
renderToString
const
head
=
Head
.
rewind
()
||
defaultHead
()
let
html
let
head
try
{
html
=
render
(
app
)
}
finally
{
head
=
Head
.
rewind
()
||
defaultHead
()
}
return
{
html
,
head
}
return
{
html
,
head
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment