add colorThemeSwitcher

This commit is contained in:
Junyi Hou 2024-03-13 16:54:18 +08:00
parent 4629494c03
commit 80298828e7
2 changed files with 2 additions and 7 deletions

View File

@ -58,11 +58,6 @@ Now enter [`localhost:1313`](http://localhost:1313/) in the address bar of your
## Feature Settings ## Feature Settings
### Dark Mode ### Dark Mode
Customize via `style` param in `params` section of config.
Options:
- `light-without-switcher` - light theme, without switcher (by default)
- `dark-without-switcher` - dark theme, without switcher
- `auto-without-switcher` - theme based on user system settings, without switcher
- `light` - light theme by default, can be switched by user to dark theme and back. Theme settings are saved for user - `light` - light theme by default, can be switched by user to dark theme and back. Theme settings are saved for user
- `dark` - dark theme by default, can be switched by user to light theme and back. Theme settings are saved for user - `dark` - dark theme by default, can be switched by user to light theme and back. Theme settings are saved for user
- `auto` - theme based on user system settings by default, can be switched by user to dark/light theme. Theme settings are saved for user (by default in example sites) - `auto` - theme based on user system settings by default, can be switched by user to dark/light theme. Theme settings are saved for user (by default in example sites)

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
{{ $dataTheme := "" }} {{ $dataTheme := "" }}
{{ if eq site.Params.style "dark-without-switcher" }} {{ if and (ne site.Params.colortheme "auto") (eq site.Params.colorthemeswitcher false) }}
{{ $dataTheme = "dark" }} {{ $dataTheme := site.Params.colortheme }}
{{ end }} {{ end }}
<html lang="{{ .Site.Params.locale | default .Site.LanguageCode }}" data-theme="{{ $dataTheme }}"> <html lang="{{ .Site.Params.locale | default .Site.LanguageCode }}" data-theme="{{ $dataTheme }}">
<head> <head>