|
- import React from "react";
- import Document, { Head, Main, NextScript } from "next/document";
- import { ServerStyleSheets } from "@material-ui/core/styles";
- import "assets/scss/nextjs-material-kit.scss?v=1.1.0";
- import theme from "../theme";
- class MyDocument extends Document {
- render() {
- return (
- <html lang="en">
- <Head>
- <meta charSet="utf-8" />
- <meta
- name="viewport"
- content="width=device-width, initial-scale=1, shrink-to-fit=no"
- />
- <meta name="theme-color" content={theme.palette.primary.main} />
- <link rel="shortcut icon" href={require("assets/img/favicons.png")} />
- <link
- rel="apple-touch-icon"
- sizes="76x76"
- href={require("assets/img/apple-icon.png")}
- />
- {/* Fonts and icons */}
- <link
- rel="stylesheet"
- type="text/css"
- href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons"
- />
- <link
- href="https://use.fontawesome.com/releases/v5.0.10/css/all.css"
- rel="stylesheet"
- />
- </Head>
- <body>
- <div id="page-transition"></div>
- <Main />
- <NextScript />
- </body>
- </html>
- );
- }
- }
-
- MyDocument.getInitialProps = async (ctx) => {
- 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(),
- ],
- };
- };
-
- export default MyDocument;
|