{"size": 1419, "ext": "js", "max_stars_repo_path": "pages/_document.js", "max_stars_repo_name": "tesarwijaya/metron", "max_stars_repo_stars_event_min_datetime": "2019-09-07T10:06:56.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-13T08:27:45.000Z", "max_issues_repo_path": "pages/_document.js", "max_issues_repo_name": "tesarwijaya/metron", "max_issues_repo_issues_event_min_datetime": "2021-03-09T16:47:11.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-02T12:51:28.000Z", "max_forks_repo_path": "pages/_document.js", "max_forks_repo_name": "tesarwijaya/metron", "max_forks_repo_forks_event_min_datetime": "2019-09-04T18:29:20.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-07T12:52:46.000Z"}
{"max_stars_count": 2, "max_issues_count": 8, "max_forks_count": 2, "avg_line_length": 26.2777777778, "max_line_length": 115, "alphanum_fraction": 0.6039464412}
import React from 'react'
import Document, { Head, Main, NextScript } from 'next/document'
import { ServerStyleSheets } from '@material-ui/styles'

import theme from 'lib/theme'
import styles from 'static/styles'

class MyDocument extends Document {
  render() {
    return (
      <html lang="en" dir="ltr">
        <Head>
          <meta charSet="utf-8" />
          <meta
            name="viewport"
            content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no"
          />
          <meta name="theme-color" content={theme.palette.primary.main} />
          {styles.map((href, key) => (<link key={key.toString()} href={href} rel="stylesheet" type="text/css" />))}
        </Head>
        <body>
          <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 fragment is rendered after the app and page rendering finish.
    styles: [
      <React.Fragment key="styles">
        {initialProps.styles}
        {sheets.getStyleElement()}
      </React.Fragment>,
    ],
  }
}

export default MyDocument
