You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
import Document, { DocumentContext, DocumentInitialProps, Html, Head, Main, NextScript } from 'next/document'
|
|
import { Fragment } from 'react'
|
|
import { ServerStyleSheet } from 'styled-components'
|
|
import { IsIsekai } from '../globals/constants'
|
|
|
|
export default class CustomDocument extends Document {
|
|
static async getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps> {
|
|
const sheet = new ServerStyleSheet()
|
|
const originalRenderPage = ctx.renderPage
|
|
|
|
try {
|
|
ctx.renderPage = () =>
|
|
originalRenderPage({
|
|
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
|
|
})
|
|
|
|
const initialProps = await Document.getInitialProps(ctx)
|
|
return {
|
|
...initialProps,
|
|
styles: [
|
|
<Fragment key="1">
|
|
{initialProps.styles}
|
|
{sheet.getStyleElement()}
|
|
</Fragment>,
|
|
],
|
|
}
|
|
} finally {
|
|
sheet.seal()
|
|
}
|
|
}
|
|
|
|
render(): JSX.Element {
|
|
return (
|
|
<Html lang="en">
|
|
<Head>
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
|
<meta name="referrer" content="no-referrer" />
|
|
|
|
{/* Remove resources which not exists
|
|
<link rel="icon" href="/icons/novelai-round.png" />
|
|
<link rel="apple-touch-icon" href="/icons/novelai-square.png" />
|
|
<link rel="mask-icon" href="/icons/pen-tip-light.svg" color="#ffffff" />
|
|
<link rel="manifest" href="/manifest.json" />
|
|
*/}
|
|
{IsIsekai && (
|
|
<>
|
|
<script id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script>
|
|
<script dangerouslySetInnerHTML={{ __html: 'LA.init({id: "JqlW3LkE9dgxYnN1",ck: "JqlW3LkE9dgxYnN1"})' }}></script>
|
|
</>
|
|
)}
|
|
</Head>
|
|
<body>
|
|
<Main />
|
|
<NextScript />
|
|
</body>
|
|
</Html>
|
|
)
|
|
}
|
|
}
|