Monorepo containing core modules of Zeichen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
883 B

  1. import * as React from 'react'
  2. import Document from 'next/document'
  3. import { ServerStyleSheet } from 'styled-components'
  4. export default class MyDocument extends Document {
  5. static async getInitialProps(ctx) {
  6. const sheet = new ServerStyleSheet()
  7. const originalRenderPage = ctx.renderPage
  8. try {
  9. ctx.renderPage = () =>
  10. originalRenderPage({
  11. enhanceApp: (App) => (props) =>
  12. sheet.collectStyles(<App {...props} />),
  13. })
  14. const initialProps = await Document.getInitialProps(ctx)
  15. return {
  16. ...initialProps,
  17. styles: (
  18. <React.Fragment>
  19. <style>{`:root { font-family: system-ui, sans-serif } body { margin: 0 }`}</style>
  20. {initialProps.styles}
  21. {sheet.getStyleElement()}
  22. </React.Fragment>
  23. ),
  24. }
  25. } finally {
  26. sheet.seal()
  27. }
  28. }
  29. }