2023-01-14 19:31:05 +00:00
|
|
|
import {Html, Head, Main, NextScript} from 'next/document'
|
2022-12-06 12:54:34 +00:00
|
|
|
|
|
|
|
const modeScript = `
|
2023-01-14 19:31:05 +00:00
|
|
|
darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
|
2022-12-06 12:54:34 +00:00
|
|
|
|
|
|
|
updateMode()
|
|
|
|
darkModeMediaQuery.addEventListener('change', updateModeWithoutTransitions)
|
|
|
|
window.addEventListener('storage', updateModeWithoutTransitions)
|
|
|
|
|
|
|
|
function updateMode() {
|
|
|
|
let isSystemDarkMode = darkModeMediaQuery.matches
|
|
|
|
let isDarkMode = window.localStorage.isDarkMode === 'true' || (!('isDarkMode' in window.localStorage) && isSystemDarkMode)
|
|
|
|
|
|
|
|
if (isDarkMode) {
|
|
|
|
document.documentElement.classList.add('dark')
|
|
|
|
} else {
|
|
|
|
document.documentElement.classList.remove('dark')
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isDarkMode === isSystemDarkMode) {
|
|
|
|
delete window.localStorage.isDarkMode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function disableTransitionsTemporarily() {
|
|
|
|
document.documentElement.classList.add('[&_*]:!transition-none')
|
|
|
|
window.setTimeout(() => {
|
|
|
|
document.documentElement.classList.remove('[&_*]:!transition-none')
|
|
|
|
}, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateModeWithoutTransitions() {
|
|
|
|
disableTransitionsTemporarily()
|
|
|
|
updateMode()
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
export default function Document() {
|
|
|
|
return (
|
|
|
|
<Html className="h-full antialiased" lang="en">
|
|
|
|
<Head>
|
|
|
|
<script dangerouslySetInnerHTML={{__html: modeScript}}/>
|
|
|
|
<link
|
|
|
|
rel="alternate"
|
|
|
|
type="application/rss+xml"
|
|
|
|
href="/rss/feed.xml"
|
2023-01-23 19:51:14 +00:00
|
|
|
title="RSS feed for ryanfreeman.dev"
|
2022-12-06 12:54:34 +00:00
|
|
|
/>
|
|
|
|
<link
|
|
|
|
rel="alternate"
|
|
|
|
type="application/feed+json"
|
|
|
|
href="/rss/feed.json"
|
2023-01-23 19:51:14 +00:00
|
|
|
title="RSS feed for ryanfreeman.dev"
|
2022-12-06 12:54:34 +00:00
|
|
|
/>
|
|
|
|
<link
|
|
|
|
rel="icon"
|
|
|
|
type="image/png"
|
|
|
|
href="/static/icons/favicon-16x16.png"
|
|
|
|
sizes="16x16"
|
|
|
|
/>
|
|
|
|
<link
|
|
|
|
rel="icon"
|
|
|
|
type="image/png"
|
|
|
|
href="/static/icons/favicon-32x32.png"
|
|
|
|
sizes="32x32"
|
|
|
|
/>
|
|
|
|
<link
|
|
|
|
rel="apple-touch-icon"
|
|
|
|
href="/static/icons/apple-touch-icon.png"
|
|
|
|
/>
|
|
|
|
</Head>
|
2023-01-14 19:31:05 +00:00
|
|
|
<script dangerouslySetInnerHTML={{__html: modeScript}}/>
|
2023-01-23 19:51:54 +00:00
|
|
|
<body className="flex h-full flex-col dark:bg-black-950">
|
2022-12-06 12:54:34 +00:00
|
|
|
<Main/>
|
|
|
|
<NextScript/>
|
|
|
|
</body>
|
|
|
|
</Html>
|
2023-01-14 19:31:05 +00:00
|
|
|
);
|
|
|
|
}
|