1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import Document, {
- Html,
- Head,
- Main,
- NextScript,
- DocumentContext,
- } from "next/document";
- import { ServerStyleSheet } from "styled-components";
- class MyDocument extends Document {
- static async getInitialProps(ctx: DocumentContext) {
- 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 lang="en">
- <Head>
- <link rel="icon" href="/favicon.ico" />
- <link rel="preconnect" href="https://fonts.googleapis.com" />
- <link
- rel="preconnect"
- href="https://fonts.gstatic.com"
- crossOrigin="anonymous"
- />
- <link
- href="https://fonts.googleapis.com/css2?family=Catamaran:wght@300;400;500;600;700&family=PT+Sans:wght@400;700&display=swap"
- rel="stylesheet"
- />
- </Head>
- <body>
- <Main />
- <NextScript />
- </body>
- </Html>
- );
- }
- }
- export default MyDocument;
|