bbgo_origin/apps/backtest-report/pages/_document.tsx

45 lines
1.0 KiB
TypeScript
Raw Permalink Normal View History

2022-05-16 17:53:51 +00:00
import Document, {DocumentContext, Head, Html, Main, NextScript} from 'next/document';
2022-05-18 17:00:45 +00:00
// ----- mantine setup
import {createStylesServer, ServerStyles} from '@mantine/next';
import {DocumentInitialProps} from "next/dist/shared/lib/utils";
// const getInitialProps = createGetInitialProps();
const stylesServer = createStylesServer();
// -----
2022-05-16 17:53:51 +00:00
class MyDocument extends Document {
2022-05-18 17:00:45 +00:00
// this is for mantine
// static getInitialProps = getInitialProps;
static async getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps> {
2022-05-16 17:53:51 +00:00
const initialProps = await Document.getInitialProps(ctx);
2022-05-18 17:00:45 +00:00
return {
...initialProps,
// use bracket [] instead of () to fix the type error
styles: [
<>
{initialProps.styles}
<ServerStyles html={initialProps.html} server={stylesServer}/>
</>
],
};
2022-05-16 17:53:51 +00:00
}
render() {
return (
<Html lang="en">
2022-05-19 02:31:37 +00:00
<Head> </Head>
2022-05-16 17:53:51 +00:00
<body>
2022-05-19 02:31:37 +00:00
<Main/>
<NextScript/>
2022-05-16 17:53:51 +00:00
</body>
</Html>
);
}
}
export default MyDocument;