diff --git a/lib/head.js b/lib/head.js
index d7b1423f..ef206c54 100644
--- a/lib/head.js
+++ b/lib/head.js
@@ -12,14 +12,15 @@ class Head extends React.Component {
}
}
-export function defaultHead () {
- return []
+const NEXT_HEAD_IDENTIFIER = 'next-head'
+
+export function defaultHead (className = NEXT_HEAD_IDENTIFIER) {
+ return []
}
function reduceComponents (components) {
return components
- .map((c) => c.props.children)
- .map((children) => React.Children.toArray(children))
+ .map((component) => React.Children.toArray(component.props.children))
.reduce((a, b) => a.concat(b), [])
.reduce((a, b) => {
if (React.Fragment && b.type === React.Fragment) {
@@ -28,12 +29,12 @@ function reduceComponents (components) {
return a.concat(b)
}, [])
.reverse()
- .concat(...defaultHead())
- .filter((c) => !!c)
+ .concat(defaultHead())
+ .filter(Boolean)
.filter(unique())
.reverse()
.map((c) => {
- const className = (c.props && c.props.className ? c.props.className + ' ' : '') + 'next-head'
+ const className = (c.props && c.props.className ? c.props.className + ' ' : '') + NEXT_HEAD_IDENTIFIER
return React.cloneElement(c, { className })
})
}