Handle dark theme

This commit is contained in:
nemunaire 2026-05-17 18:41:08 +08:00
commit 98afab44ca
2 changed files with 4 additions and 0 deletions

View file

@ -1,4 +1,5 @@
<head>
<script>document.documentElement.setAttribute('data-bs-theme',window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light')</script>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">

View file

@ -1,6 +1,9 @@
<script src="/js/bootstrap.bundle.min.js"></script>
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
<script>
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function(e) {
document.documentElement.setAttribute('data-bs-theme', e.matches ? 'dark' : 'light');
});
window.addEventListener("scroll", function () {
if (window.scrollY > 100) {
document.getElementById("mainnav").classList.add("scrolled");