diff --git a/pages/_document.tsx b/pages/_document.tsx index afe55bb..9082251 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -38,7 +38,50 @@ export default class MyDocument extends Document {
- + diff --git a/public/noflash.js b/public/noflash.js deleted file mode 100644 index 39fd823..0000000 --- a/public/noflash.js +++ /dev/null @@ -1,42 +0,0 @@ -/* eslint-disable */ - -// Insert this script in your index.html right after the tag. -// This will help to prevent a flash if dark mode is the default. - -;(function () { - // Change these if you use something different in your hook. - var storageKey = 'darkMode' - var classNameDark = 'dark-mode' - var classNameLight = 'light-mode' - - function setClassOnDocumentBody(darkMode) { - document.body.classList.add(darkMode ? classNameDark : classNameLight) - document.body.classList.remove(darkMode ? classNameLight : classNameDark) - } - - var preferDarkQuery = '(prefers-color-scheme: dark)' - var mql = window.matchMedia(preferDarkQuery) - var supportsColorSchemeQuery = mql.media === preferDarkQuery - var localStorageTheme = null - try { - localStorageTheme = localStorage.getItem(storageKey) - } catch (err) {} - var localStorageExists = localStorageTheme !== null - if (localStorageExists) { - localStorageTheme = JSON.parse(localStorageTheme) - } - - // Determine the source of truth - if (localStorageExists) { - // source of truth from localStorage - setClassOnDocumentBody(localStorageTheme) - } else if (supportsColorSchemeQuery) { - // source of truth from system - setClassOnDocumentBody(mql.matches) - localStorage.setItem(storageKey, mql.matches) - } else { - // source of truth from document.body - var isDarkMode = document.body.classList.contains(classNameDark) - localStorage.setItem(storageKey, JSON.stringify(isDarkMode)) - } -})()