mirror of
https://github.com/zhigang1992/react.git
synced 2026-01-25 22:26:32 +08:00
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import Document, { Html, Head, Main, NextScript } from 'next/document'
|
|
|
|
class MyDocument extends Document {
|
|
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
|