2023-03-29 10:07:34 +03:00

50 lines
1.3 KiB
JavaScript

/* eslint-disable @typescript-eslint/explicit-member-accessibility */
import { metaFavicon } from '@/config/meta';
import Document, { Head, Html, Main, NextScript } from 'next/document';
import { ServerStyleSheet } from 'styled-components';
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 lang="ru" translate="no">
<Head>
<meta charSet="utf-8" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Лизинговый калькулятор - Эволюция" />
{metaFavicon}
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}