51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
import {
|
|
DocumentContext,
|
|
Document,
|
|
Html,
|
|
DocumentHead,
|
|
Main,
|
|
BlitzScript /*DocumentContext*/,
|
|
} from "blitz";
|
|
|
|
import React from "react";
|
|
import { ServerStyleSheets } from "@mui/styles";
|
|
|
|
class MyDocument extends Document {
|
|
static async getInitialProps(ctx: DocumentContext) {
|
|
const sheets = new ServerStyleSheets();
|
|
const originalRenderPage = ctx.renderPage;
|
|
|
|
ctx.renderPage = () => originalRenderPage({
|
|
enhanceApp: App => props => sheets.collect(<App {...props} />)
|
|
});
|
|
|
|
const initialProps = await Document.getInitialProps(ctx);
|
|
|
|
return {
|
|
...initialProps,
|
|
styles: [...React.Children.toArray(initialProps.styles), sheets.getStyleElement()]
|
|
};
|
|
}
|
|
|
|
// Only uncomment if you need to customize this behaviour
|
|
// static async getInitialProps(ctx: DocumentContext) {
|
|
// const initialProps = await Document.getInitialProps(ctx)
|
|
// return {...initialProps}
|
|
// }
|
|
|
|
render() {
|
|
return (
|
|
<Html lang="en">
|
|
<DocumentHead />
|
|
<title>Item Finder</title>
|
|
<body>
|
|
<Main />
|
|
<BlitzScript />
|
|
</body>
|
|
</Html>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default MyDocument
|