Skip to content

Commit fbe01bb

Browse files
author
Maxwell Lang
committed
Fix broken document
1 parent a8c9b14 commit fbe01bb

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

pages/_document.js

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
1-
import { Head } from 'next/document';
1+
import Document, { Html, Head, Main, NextScript } from 'next/document'
22

33
export default class MyDocument extends Document {
4+
static async getInitialProps(ctx) {
5+
const initialProps = await Document.getInitialProps(ctx)
6+
return { ...initialProps }
7+
}
8+
49
render() {
510
return (
6-
<Head>
7-
<script src="https://www.googletagmanager.com/gtag/js?id=G-24SMZDF52M" async />
11+
<Html>
12+
<Head>
13+
<script src="https://www.googletagmanager.com/gtag/js?id=G-24SMZDF52M" async />
814

9-
<script
10-
dangerouslySetInnerHTML={{
11-
__html: `
12-
window.dataLayer = window.dataLayer || [];
13-
function gtag(){dataLayer.push(arguments);}
14-
gtag('js', new Date());
15-
gtag('config', 'G-24SMZDF52M', { page_path: window.location.pathname });
16-
`,
17-
}}
18-
/>
19-
</Head>
20-
);
15+
<script
16+
dangerouslySetInnerHTML={{
17+
__html: `
18+
window.dataLayer = window.dataLayer || [];
19+
function gtag(){dataLayer.push(arguments);}
20+
gtag('js', new Date());
21+
gtag('config', 'G-24SMZDF52M', { page_path: window.location.pathname });
22+
`,
23+
}}
24+
/>
25+
</Head>
26+
<body>
27+
<Main />
28+
<NextScript />
29+
</body>
30+
</Html>
31+
)
2132
}
22-
}
33+
}

0 commit comments

Comments
 (0)