2022-08-02 13:56:12 +00:00
|
|
|
import NextDocument, { DocumentContext, Head, Html, Main, NextScript } from 'next/document'
|
|
|
|
import { getCssText } from '~styles'
|
|
|
|
import { GA_TRACKING_ID } from '~utils/gtag'
|
2021-09-04 12:02:13 +00:00
|
|
|
|
|
|
|
class MyDocument extends NextDocument {
|
2022-05-14 13:15:55 +00:00
|
|
|
static async getInitialProps(ctx: DocumentContext): Promise<any> {
|
2021-11-26 15:14:10 +00:00
|
|
|
const initialProps = await NextDocument.getInitialProps(ctx)
|
2021-09-04 12:02:13 +00:00
|
|
|
|
2021-11-26 15:14:10 +00:00
|
|
|
return {
|
|
|
|
...initialProps,
|
|
|
|
styles: (
|
|
|
|
<>
|
|
|
|
{initialProps.styles}
|
|
|
|
<style id="stitches" dangerouslySetInnerHTML={{ __html: getCssText() }} />
|
|
|
|
</>
|
|
|
|
),
|
2021-09-04 12:02:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-14 13:15:55 +00:00
|
|
|
render() {
|
2021-09-04 12:02:13 +00:00
|
|
|
return (
|
|
|
|
<Html lang="en">
|
|
|
|
<Head>
|
|
|
|
<script async src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`} />
|
|
|
|
<script
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: `
|
|
|
|
window.dataLayer = window.dataLayer || [];
|
|
|
|
function gtag(){dataLayer.push(arguments);}
|
|
|
|
gtag('js', new Date());
|
|
|
|
gtag('config', '${GA_TRACKING_ID}', {
|
|
|
|
page_path: window.location.pathname,
|
|
|
|
});
|
|
|
|
`,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Head>
|
|
|
|
<body>
|
|
|
|
<Main />
|
|
|
|
<NextScript />
|
|
|
|
</body>
|
|
|
|
</Html>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MyDocument
|