-
Notifications
You must be signed in to change notification settings - Fork 332
/
Copy path_document.tsx
61 lines (57 loc) · 1.51 KB
/
_document.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import Document, { Html, Head, Main, NextScript, DocumentContext } from 'next/document'
import { CssBaseline } from 'components'
class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx)
const styles = CssBaseline.flush()
return {
...initialProps,
styles: (
<>
{initialProps.styles}
{styles}
</>
),
}
}
render() {
return (
<Html>
<Head />
<body>
<script
dangerouslySetInnerHTML={{
__html: `
(function(){
if (!window.localStorage) return;
if (window.localStorage.getItem('theme') === 'dark') {
document.documentElement.style.background = '#000';
document.body.style.background = '#000';
};
})()
`,
}}
/>
<Main />
<NextScript />
<script
async
src="https://www.googletagmanager.com/gtag/js?id=UA-110371817-12"
/>
<script
async
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-110371817-12');
`,
}}
/>
</body>
</Html>
)
}
}
export default MyDocument