preview-head.html 517 B

12345678910111213
  1. <script>
  2. function handleThemeColor() {
  3. let themeColor = window.localStorage.getItem("theme-toggle:prefers-color-scheme");
  4. themeColor = themeColor ? JSON.parse(themeColor) : "auto";
  5. if (themeColor === "auto") {
  6. themeColor = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
  7. } else if (!themeColor) {
  8. themeColor = "light";
  9. }
  10. document.documentElement.setAttribute("data-color-scheme", themeColor);
  11. }
  12. handleThemeColor();
  13. </script>