mirror of
https://github.com/iconoir-icons/iconoir
synced 2024-05-17 22:06:42 +02:00
64 lines
1.4 KiB
TypeScript
64 lines
1.4 KiB
TypeScript
import Document, {
|
|
DocumentContext,
|
|
DocumentInitialProps,
|
|
Head,
|
|
Html,
|
|
Main,
|
|
NextScript,
|
|
} from 'next/document';
|
|
import { ServerStyleSheet } from 'styled-components';
|
|
|
|
export default class IconoirDocument extends Document {
|
|
static async getInitialProps(
|
|
ctx: DocumentContext,
|
|
): Promise<DocumentInitialProps> {
|
|
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 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=DM+Sans:wght@400;500;700&family=IBM+Plex+Mono:wght@400;700&display=swap"
|
|
rel="stylesheet"
|
|
/>
|
|
</Head>
|
|
<body>
|
|
<Main />
|
|
<NextScript />
|
|
</body>
|
|
</Html>
|
|
);
|
|
}
|
|
}
|