-
Notifications
You must be signed in to change notification settings - Fork 20
/
_document.js
39 lines (37 loc) · 1.26 KB
/
_document.js
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
import clsx from 'clsx';
import NextDocument, { Html, Head, Main, NextScript } from 'next/document';
export default class Document extends NextDocument {
static async getInitialProps(ctx) {
const initialProps = await NextDocument.getInitialProps(ctx)
return { ...initialProps }
}
render() {
return (
<Html lang="en" className="dark [--scroll-mt:9.875rem] lg:[--scroll-mt:6.3125rem]">
<Head>
<script
dangerouslySetInnerHTML={{
__html: `
try {
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark')
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0B1120')
} else {
document.documentElement.classList.remove('dark')
}
} catch (_) {}
`,
}}
/>
</Head>
<body
className="bg-white dark:bg-slate-900 antialiased text-slate-500 dark:text-slate-400"
>
<Main />
<NextScript />
<script> </script>
</body>
</Html>
)
}
}