Skip to content

Commit

Permalink
fix: keep prefered theme
Browse files Browse the repository at this point in the history
  • Loading branch information
atsuyaw committed Dec 1, 2023
1 parent 4b31067 commit 201d709
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion v4/assets/js/check-theme-prefer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const darkStore = localStorage.getItem("dark-store");
const docEle = document.documentElement;
console.log(darkStore);
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)");
if (darkStore === "true") {
docEle.classList.add("dark-mode");
Expand Down
4 changes: 1 addition & 3 deletions v4/layouts/partials/check-theme-prefer.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{ $jsToConcat := resources.Get "js/check-theme-prefer.js" }}
{{ $checkThemePrefer := slice $jsToConcat | resources.Concat "check-theme-prefer.js" }}

{{ $checkThemePrefer := resources.Get "js/check-theme-prefer.js" }}
{{ if or (.Site.IsServer) (eq hugo.Environment "development") }}
<script src="{{ $checkThemePrefer.Permalink }}"></script>
{{ else }}
Expand Down
2 changes: 1 addition & 1 deletion v4/layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h3 class="title">
{{ end }}
</div>
<div class="selectors">
{{ if .Site.Params.enableLightDarkMode | default false }}
{{ if .Site.Params.enableLightDarkTheme | default false }}
<div class="light-dark-mode">
<button id="light-dark-toggle" class="fa-solid fa-sun"></button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion v4/tests/exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ disqusShortname = "bilberry-hugo-theme"
css_modules = []
js_modules = []

enableLightDarkThemeMode = true
enableLightDarkTheme = true

# Description and meta data for the search engines
author = "Lednerb"
Expand Down

0 comments on commit 201d709

Please sign in to comment.