All files / app/pages _document.tsx

0% Statements 0/9
0% Branches 0/3
0% Functions 0/2
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                                                                 
import InitColorSchemeScript from "@mui/material/InitColorSchemeScript";
import { documentGetInitialProps, DocumentHeadTags, DocumentHeadTagsProps } from "@mui/material-nextjs/v15-pagesRouter";
import { DEFAULT_LOCALE } from "i18n/locales";
import { DocumentContext, DocumentProps, Head, Html, Main, NextScript } from "next/document";
import { theme } from "theme";
 
export default function MyDocument(props: DocumentProps & DocumentHeadTagsProps) {
  return (
    <Html lang={props.locale ?? DEFAULT_LOCALE}>
      <Head>
        <DocumentHeadTags {...props} />
 
        <link rel="preconnect" href="https://cdn.couchers.org" />
        <meta name="theme-color" content={theme.palette.primary.main} />
        <link rel="manifest" href="/manifest.json" />
        <link rel="apple-touch-icon" href="/logo512.png" />
        <link rel="stylesheet" href="https://cdn.couchers.org/fonts/ubuntu/ubuntu.css" />
        <link rel="stylesheet" href="https://cdn.couchers.org/fonts/wordmark/wordmark.css" />
        {/* Antibot script. Its fingerprint loop leaks WebGL contexts, so we skip it in dev. */}
        {process.env.NODE_ENV !== "development" && (
          <script
            dangerouslySetInnerHTML={{
              __html: `window.addEventListener('load',function(){var s=document.createElement('script');s.async=true;s.src='https://twdl.couchers.org/script.js';document.head.appendChild(s)})`,
            }}
          />
        )}
      </Head>
      <body>
        <InitColorSchemeScript defaultMode="system" attribute="data-mui-color-scheme" />
        <Main />
        <NextScript />
      </body>
    </Html>
  );
}
 
MyDocument.getInitialProps = async (ctx: DocumentContext) => {
  const finalProps = await documentGetInitialProps(ctx);
  return finalProps;
};