2022-01-27 13:53:41 +00:00
|
|
|
import Document, { Html, Head, Main, NextScript } from "next/document";
|
|
|
|
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>
|
2022-02-02 16:15:21 +00:00
|
|
|
<Head>{this.props.styleTags}</Head>
|
2022-01-27 13:53:41 +00:00
|
|
|
<body>
|
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
|
|
|
</Html>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|