Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanxiaobei/hugo-paper.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornanxiaobei <nanxiaobei@gmail.com>2022-10-24 16:31:58 +0300
committernanxiaobei <nanxiaobei@gmail.com>2022-10-24 16:31:58 +0300
commit2ba0c005b93e667cc940530f550490cc2499bf0f (patch)
tree525e8caef9bca9037620440f570b270f80bced38
parentbdeb5df5a5079bbbb8ee5f3e41a8a05143d142ef (diff)
refine theme logic
-rw-r--r--layouts/partials/header.html8
1 files changed, 6 insertions, 2 deletions
diff --git a/layouts/partials/header.html b/layouts/partials/header.html
index 32c5638..d7845b2 100644
--- a/layouts/partials/header.html
+++ b/layouts/partials/header.html
@@ -37,8 +37,12 @@
// init
const darkScheme = window.matchMedia('(prefers-color-scheme: dark)');
- const darkVal = localStorage.getItem('dark');
- setDark(darkVal ? darkVal === 'true' : darkScheme.matches);
+ if (htmlClass.contains('dark')) {
+ setDark(true);
+ } else {
+ const darkVal = localStorage.getItem('dark');
+ setDark(darkVal ? darkVal === 'true' : darkScheme.matches);
+ }
// listen system
darkScheme.addEventListener('change', (event) => {