diff --git a/docs/pages/_document.js b/docs/pages/_document.js index f9dfc9a7f73a6..1fd83562b13f5 100644 --- a/docs/pages/_document.js +++ b/docs/pages/_document.js @@ -1,3 +1,292 @@ -import MyDocument from '@mui/monorepo/docs/pages/_document'; +import * as React from 'react'; +import Script from 'next/script'; +import { documentGetInitialProps } from '@mui/material-nextjs/v13-pagesRouter'; +import { ServerStyleSheets as JSSServerStyleSheets } from '@mui/styles'; +import { ServerStyleSheet } from 'styled-components'; +import Document, { Html, Head, Main, NextScript } from 'next/document'; +import GlobalStyles from '@mui/material/GlobalStyles'; +import MuiInitColorSchemeScript from '@mui/material/InitColorSchemeScript'; +import JoyInitColorSchemeScript from '@mui/joy/InitColorSchemeScript'; +import { pathnameToLanguage } from 'docs/src/modules/utils/helpers'; +import createEmotionCache from 'docs/src/createEmotionCache'; +import { getMetaThemeColor } from '@mui/docs/branding'; -export default MyDocument; +// You can find a benchmark of the available CSS minifiers under +// https://github.com/GoalSmashers/css-minification-benchmark +// We have found that clean-css is faster than cssnano but the output is larger. +// Waiting for https://github.com/cssinjs/jss/issues/279 +// 4% slower but 12% smaller output than doing it in a single step. +// +// It's using .browserslistrc +let prefixer; +let cleanCSS; +if (process.env.NODE_ENV === 'production') { + /* eslint-disable global-require */ + const postcss = require('postcss'); + const autoprefixer = require('autoprefixer'); + const CleanCSS = require('clean-css'); + /* eslint-enable global-require */ + + prefixer = postcss([autoprefixer]); + cleanCSS = new CleanCSS(); +} + +const PRODUCTION_GA = + process.env.DEPLOY_ENV === 'production' || process.env.DEPLOY_ENV === 'staging'; + +const GOOGLE_ANALYTICS_ID_V4 = PRODUCTION_GA ? 'G-5NXDQLC2ZK' : 'G-XJ83JQEK7J'; + +export default class MyDocument extends Document { + render() { + const { canonicalAsServer, userLanguage } = this.props; + + return ( + + + {/* + manifest.json provides metadata used when your web app is added to the + homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ + */} + + {/* PWA primary color */} + + + + {/* iOS Icon */} + + {/* SEO */} + + + {/* + Preconnect allows the browser to setup early connections before an HTTP request + is actually sent to the server. + This includes DNS lookups, TLS negotiations, TCP handshakes. + */} + + + + {/* ========== Font preload (prevent font flash) ============= */} + 6kb) + href="/static/fonts/GeneralSans-Semibold-subset.woff2" + as="font" + type="font/woff2" + crossOrigin="anonymous" + /> +