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
b065dafa
Commit
b065dafa
authored
Sep 29, 2018
by
Henrik Wenz
Committed by
Tim Neutkens
Sep 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor head keys (#5326)
We don't need to `React.cloneElement`, twice.
parent
df41997d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
head.js
lib/head.js
+6
-3
document.js
server/document.js
+1
-1
No files found.
lib/head.js
View file @
b065dafa
...
...
@@ -15,7 +15,9 @@ class Head extends React.Component {
const
NEXT_HEAD_IDENTIFIER
=
'next-head'
export
function
defaultHead
(
className
=
NEXT_HEAD_IDENTIFIER
)
{
return
[
<
meta
charSet
=
'utf-8'
className
=
{
className
}
/>
]
return
[
<
meta
key
=
'charSet'
charSet
=
'utf-8'
className
=
{
className
}
/
>
]
}
function
reduceComponents
(
components
)
{
...
...
@@ -33,9 +35,10 @@ function reduceComponents (components) {
.
filter
(
Boolean
)
.
filter
(
unique
())
.
reverse
()
.
map
((
c
)
=>
{
.
map
((
c
,
i
)
=>
{
const
className
=
(
c
.
props
&&
c
.
props
.
className
?
c
.
props
.
className
+
' '
:
''
)
+
NEXT_HEAD_IDENTIFIER
return
React
.
cloneElement
(
c
,
{
className
})
const
key
=
c
.
key
||
i
return
React
.
cloneElement
(
c
,
{
key
,
className
})
})
}
...
...
server/document.js
View file @
b065dafa
...
...
@@ -116,7 +116,7 @@ export class Head extends Component {
}
return
<
head
{...
this
.
props
}
>
{
(
head
||
[]).
map
((
h
,
i
)
=>
React
.
cloneElement
(
h
,
{
key
:
h
.
key
||
i
}))
}
{
head
}
{
page
!==
'/_error'
&&
<
link
rel
=
'preload'
href
=
{
`
${
assetPrefix
}
/_next/static/
${
buildId
}
/pages
${
pagePathname
}
`
}
as
=
'script'
nonce
=
{
this
.
props
.
nonce
}
/>
}
<
link
rel
=
'preload'
href
=
{
`
${
assetPrefix
}
/_next/static/
${
buildId
}
/pages/_app.js`
}
as
=
'script'
nonce
=
{
this
.
props
.
nonce
}
/
>
<
link
rel
=
'preload'
href
=
{
`
${
assetPrefix
}
/_next/static/
${
buildId
}
/pages/_error.js`
}
as
=
'script'
nonce
=
{
this
.
props
.
nonce
}
/
>
...
...
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