2023-01-10 11:33:54 +03:00
|
|
|
/* eslint-disable react/no-danger */
|
|
|
|
import { readFileSync } from 'fs';
|
|
|
|
import { join } from 'path';
|
2023-08-02 23:41:08 +03:00
|
|
|
import { Html, Head, Main, NextScript } from 'next/document';
|
2023-01-10 11:33:54 +03:00
|
|
|
|
|
|
|
class InlineStylesHead extends Head {
|
|
|
|
getCssLinks: Head['getCssLinks'] = ({ allFiles }) => {
|
|
|
|
const { assetPrefix } = this.context;
|
|
|
|
if (!allFiles || allFiles.length === 0) return null;
|
|
|
|
return allFiles
|
|
|
|
.filter((file: any) => /\.css$/.test(file))
|
|
|
|
.map((file: any) => (
|
|
|
|
<style
|
|
|
|
key={file}
|
|
|
|
nonce={this.props.nonce}
|
|
|
|
data-href={`${assetPrefix}/_next/${file}`}
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: readFileSync(join(process.cwd(), '.next', file), 'utf-8'),
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-19 21:08:58 +03:00
|
|
|
export default function Document() {
|
|
|
|
return (
|
|
|
|
<Html lang="en">
|
2023-01-10 11:33:54 +03:00
|
|
|
<InlineStylesHead />
|
2022-12-19 21:08:58 +03:00
|
|
|
<body>
|
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
|
|
|
</Html>
|
|
|
|
);
|
|
|
|
}
|