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

View File

@ -1,10 +1,11 @@
{{ $style := "light-without-switcher" }} {{ $colorTheme := "light-without-switcher" }}
{{ if and (isset site.Params "style") (ne site.Params.style "") }}
{{ $style = site.Params.style | lower }} {{ if and (isset site.Params "colortheme") (ne site.Params.colortheme "") }}
{{ $colorTheme = site.Params.colortheme | lower }}
{{ end }} {{ end }}
{{ if not (in (slice "light-without-switcher" "dark-without-switcher") $style) }} {{ if not (in (slice "light-without-switcher" "dark-without-switcher") $colorTheme) }}
{{ if ne "auto-without-switcher" $style }} {{ if site.Params.colorthemeswitcher }}
<div class="theme-switcher"> <div class="theme-switcher">
{{ partial "font-awesome.html" (dict "iconName" "theme-light" "custom" false) }} {{ partial "font-awesome.html" (dict "iconName" "theme-light" "custom" false) }}
</div> </div>
@ -12,7 +13,7 @@
<script> <script>
const STORAGE_KEY = 'user-color-scheme' const STORAGE_KEY = 'user-color-scheme'
const defaultTheme = {{ $style }} const defaultTheme = {{ $colorTheme }}
let currentTheme let currentTheme
let switchButton let switchButton