Files
personal-site/pages/_document.js
T

20 lines
704 B
JavaScript
Raw Normal View History

import { Html, Head, Main, NextScript } from 'next/document';
// Set the theme before first paint to avoid a light/dark flash.
const themeScript = `(function(){try{var t=localStorage.getItem('theme');if(!t){t=window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light'}document.documentElement.dataset.theme=t}catch(e){}})();`;
export default function Document() {
return (
<Html lang="en">
<Head>
<link rel="preload" href="/fonts/inter_font.ttf" as="font" type="font/ttf" crossOrigin="anonymous" />
<script dangerouslySetInnerHTML={{ __html: themeScript }} />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}