2019-04-23 16:48:33 +09:00
|
|
|
import React from "react";
|
2019-07-09 15:46:11 +09:00
|
|
|
import Document, {
|
|
|
|
DocumentContext,
|
|
|
|
DocumentInitialProps,
|
|
|
|
Html,
|
|
|
|
Head,
|
|
|
|
Main,
|
|
|
|
NextScript
|
|
|
|
} from "next/document";
|
|
|
|
import { ServerStyleSheets } from "@material-ui/styles";
|
|
|
|
import { theme } from "../styles/MainTheme";
|
2019-04-23 16:48:33 +09:00
|
|
|
export default class extends Document {
|
2019-07-09 15:46:11 +09:00
|
|
|
static getInitialProps = async (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: [initialProps.styles, sheets.getStyleElement()]
|
|
|
|
} as DocumentInitialProps;
|
|
|
|
};
|
|
|
|
|
2019-04-23 16:48:33 +09:00
|
|
|
render() {
|
|
|
|
return (
|
2019-07-09 15:46:11 +09:00
|
|
|
<Html lang="ja" dir="ltr">
|
|
|
|
<Head>
|
|
|
|
<meta
|
|
|
|
name="viewport"
|
|
|
|
content="width=device-width,minimum-scale=1,initial-scale=1"
|
|
|
|
/>
|
|
|
|
<meta name="theme-color" content={theme.palette.primary.main} />
|
|
|
|
<link
|
|
|
|
rel="stylesheet"
|
|
|
|
href="https://fonts.googleapis.com/css?family=Noto+Sans+JP&display=swap"
|
|
|
|
/>
|
|
|
|
</Head>
|
2019-04-23 16:48:33 +09:00
|
|
|
<body>
|
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
2019-07-09 15:46:11 +09:00
|
|
|
</Html>
|
2019-04-23 16:48:33 +09:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|