rename "style" to "colorTheme", add "colorThemeSwitcher"

This commit is contained in:
Junyi Hou 2024-03-13 16:42:54 +08:00
parent 9e2a23e83b
commit 4629494c03
2 changed files with 58 additions and 57 deletions

View File

@ -21,12 +21,12 @@
{{ partial "favicons.html" . }}
{{ $style := "light-without-switcher" }}
{{ if and (isset site.Params "style") (ne site.Params.style "") }}
{{ $style = site.Params.style | lower }}
{{ $colorTheme := "light-without-switcher" }}
{{ if and (isset site.Params "colortheme") (ne site.Params.colortheme "") }}
{{ $colorTheme = site.Params.colortheme | lower }}
{{ end }}
{{ if not (in (slice "light-without-switcher" "dark-without-switcher") $style) }}
{{ if not (in (slice "light-without-switcher" "dark-without-switcher") $colorTheme) }}
<style>
body {
visibility: hidden;

View File

@ -1,18 +1,19 @@
{{ $style := "light-without-switcher" }}
{{ if and (isset site.Params "style") (ne site.Params.style "") }}
{{ $style = site.Params.style | lower }}
{{ $colorTheme := "light-without-switcher" }}
{{ if and (isset site.Params "colortheme") (ne site.Params.colortheme "") }}
{{ $colorTheme = site.Params.colortheme | lower }}
{{ end }}
{{ if not (in (slice "light-without-switcher" "dark-without-switcher") $style) }}
{{ if ne "auto-without-switcher" $style }}
<div class="theme-switcher">
{{ if not (in (slice "light-without-switcher" "dark-without-switcher") $colorTheme) }}
{{ if site.Params.colorthemeswitcher }}
<div class="theme-switcher">
{{ partial "font-awesome.html" (dict "iconName" "theme-light" "custom" false) }}
</div>
{{ end }}
</div>
{{ end }}
<script>
<script>
const STORAGE_KEY = 'user-color-scheme'
const defaultTheme = {{ $style }}
const defaultTheme = {{ $colorTheme }}
let currentTheme
let switchButton
@ -61,5 +62,5 @@
document.body.style.visibility = 'visible';
document.body.style.opacity = 1;
}
</script>
</script>
{{ end }}