2020-09-09 21:09:51 +00:00
|
|
|
import Document, {
|
|
|
|
Html, Head, Main, NextScript,
|
2020-09-12 21:53:41 +00:00
|
|
|
} from 'next/document';
|
|
|
|
import { ServerStyleSheet } from 'styled-components';
|
2020-09-09 21:09:51 +00:00
|
|
|
|
|
|
|
export default class MyDocument extends Document {
|
|
|
|
static async getInitialProps(ctx) {
|
|
|
|
const sheet = new ServerStyleSheet()
|
|
|
|
const originalRenderPage = ctx.renderPage
|
|
|
|
|
|
|
|
try {
|
|
|
|
ctx.renderPage = () =>
|
|
|
|
originalRenderPage({
|
|
|
|
enhanceApp: (App) => (props) =>
|
|
|
|
sheet.collectStyles(<App {...props} />),
|
|
|
|
})
|
|
|
|
|
|
|
|
const initialProps = await Document.getInitialProps(ctx)
|
|
|
|
return {
|
|
|
|
...initialProps,
|
|
|
|
styles: (
|
|
|
|
<>
|
|
|
|
{initialProps.styles}
|
|
|
|
{sheet.getStyleElement()}
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
sheet.seal()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Html>
|
|
|
|
<Head>
|
|
|
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
|
|
|
|
<link rel="icon" href="/icon.png" type="image/png"/>
|
|
|
|
</Head>
|
|
|
|
<body>
|
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
|
|
|
</Html>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|