Currently HTML code of shields.io contains two `<title>` elements. This PR removes an extra title element. Before change: ```bash > curl https://shields.io -s | egrep "<title.*/title>" -o <title class="next-head">Shields.io: Quality metadata badges for open source projects</title> <title>My page</title> ``` After change: ```bash > curl http://localhost:8080 -s | egrep "<title.*/title>" -o <title class="next-head">Shields.io: Quality metadata badges for open source projects</title> ```
29 lines
704 B
JavaScript
29 lines
704 B
JavaScript
// https://www.styled-components.com/docs/advanced#nextjs
|
|
|
|
import Document, { Head, Main, NextScript } from 'next/document'
|
|
import React from 'react'
|
|
import { ServerStyleSheet } from 'styled-components'
|
|
|
|
export default class MyDocument extends Document {
|
|
static getInitialProps({ renderPage }) {
|
|
const sheet = new ServerStyleSheet()
|
|
const page = renderPage(App => props =>
|
|
sheet.collectStyles(<App {...props} />)
|
|
)
|
|
const styleTags = sheet.getStyleElement()
|
|
return { ...page, styleTags }
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<html>
|
|
<Head>{this.props.styleTags}</Head>
|
|
<body>
|
|
<Main />
|
|
<NextScript />
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|
|
}
|