|
@@ -1,3 +1,4 @@ |
|
|
|
|
|
import pkg from '../../../../package.json' |
|
|
import Document, { Html, Head, Main, NextScript, DocumentContext } from 'next/document' |
|
|
import Document, { Html, Head, Main, NextScript, DocumentContext } from 'next/document' |
|
|
import { ServerStyleSheet } from 'styled-components' |
|
|
import { ServerStyleSheet } from 'styled-components' |
|
|
|
|
|
|
|
@@ -5,6 +6,7 @@ export default class MyDocument extends Document { |
|
|
static async getInitialProps(ctx: DocumentContext) { |
|
|
static async getInitialProps(ctx: DocumentContext) { |
|
|
const sheet = new ServerStyleSheet() |
|
|
const sheet = new ServerStyleSheet() |
|
|
const originalRenderPage = ctx.renderPage |
|
|
const originalRenderPage = ctx.renderPage |
|
|
|
|
|
const publicUrl = process.env.NODE_ENV === 'production' ? pkg.homepage : '' |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
ctx.renderPage = () => |
|
|
ctx.renderPage = () => |
|
@@ -19,9 +21,9 @@ export default class MyDocument extends Document { |
|
|
styles: ( |
|
|
styles: ( |
|
|
<> |
|
|
<> |
|
|
{initialProps.styles} |
|
|
{initialProps.styles} |
|
|
<link rel="stylesheet" href="/global.css" /> |
|
|
|
|
|
<link rel="stylesheet" title="Dark" href="/theme/dark.css" /> |
|
|
|
|
|
<link rel="alternate stylesheet" title="Light" href="/theme/light.css" /> |
|
|
|
|
|
|
|
|
<link rel="stylesheet" href={`${publicUrl}/global.css`} /> |
|
|
|
|
|
<link rel="stylesheet" title="Dark" href={`${publicUrl}/theme/dark.css`} /> |
|
|
|
|
|
<link rel="alternate stylesheet" title="Light" href={`${publicUrl}/theme/light.css`} /> |
|
|
{sheet.getStyleElement()} |
|
|
{sheet.getStyleElement()} |
|
|
</> |
|
|
</> |
|
|
), |
|
|
), |
|
|