Files
react/pages/_document.tsx
2020-05-06 14:25:10 +08:00

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