forked from tailwindlabs/tailwindcss.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_document.js
58 lines (54 loc) · 2.32 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import clsx from 'clsx'
import NextDocument, { Html, Head, Main, NextScript } from 'next/document'
const FAVICON_VERSION = 3
function v(href) {
return `${href}?v=${FAVICON_VERSION}`
}
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>
<link rel="apple-touch-icon" sizes="180x180" href={v('/favicons/apple-touch-icon.png')} />
<link rel="icon" type="image/png" sizes="32x32" href={v('/favicons/favicon-32x32.png')} />
<link rel="icon" type="image/png" sizes="16x16" href={v('/favicons/favicon-16x16.png')} />
<link rel="manifest" href={v('/favicons/site.webmanifest')} />
<link rel="mask-icon" href={v('/favicons/safari-pinned-tab.svg')} color="#38bdf8" />
<link rel="shortcut icon" href={v('/favicons/favicon.ico')} />
<meta name="apple-mobile-web-app-title" content="Tailwind CSS" />
<meta name="application-name" content="Tailwind CSS" />
<meta name="msapplication-TileColor" content="#38bdf8" />
<meta name="msapplication-config" content={v('/favicons/browserconfig.xml')} />
<meta name="theme-color" content="#f8fafc" />
<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={clsx('antialiased text-slate-500 dark:text-slate-400', {
'bg-white dark:bg-slate-900': !this.props.dangerousAsPath.startsWith('/examples/'),
})}
>
<Main />
<NextScript />
<script> </script>
</body>
</Html>
)
}
}