Add themechange v0.1

This commit is contained in:
Pablo Moyano
2023-10-06 18:11:59 +02:00
parent f57e2d5b1c
commit 70b7242199
2 changed files with 27 additions and 20 deletions

View File

@ -16,26 +16,6 @@ const { title } = Astro.props;
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
<!-- Theme manager -->
<script is:inline>
// ☝️ This script prevent the FART effect.
if (localStorage.getItem("theme") === null) {
document.documentElement.setAttribute("data-theme", "light");
} else
document.documentElement.setAttribute(
"data-theme",
localStorage.getItem("theme")
);
// "theme" LocalStorage value is set by the package to remember user preference.
// The value is checked and applyed before rendering anything.
</script>
<script>
import { themeChange } from 'theme-change';
themeChange();
// 👆 you could import the CDN directly instead of these two lines
</script>
</head>
<body>