diff options
| author | eltrac <hi@eltr.ac> | 2026-04-15 13:45:14 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-04-15 13:45:14 +0800 |
| commit | 63e45106035f4e395514b14f1edb8b0b68b231c4 (patch) | |
| tree | b585e7f718ca3ae989833a77eb5bbb738a093de1 | |
| parent | b807f9b6efe25f414173385ae248cd205ebd5bb9 (diff) | |
refactor: move lang/theme switch to separate partials
| -rw-r--r-- | layouts/_partials/header/lang-switch.html | 17 | ||||
| -rw-r--r-- | layouts/_partials/header/other-navigation.html | 30 | ||||
| -rw-r--r-- | layouts/_partials/header/theme-switch.html | 9 |
3 files changed, 28 insertions, 28 deletions
diff --git a/layouts/_partials/header/lang-switch.html b/layouts/_partials/header/lang-switch.html new file mode 100644 index 0000000..252baee --- /dev/null +++ b/layouts/_partials/header/lang-switch.html @@ -0,0 +1,17 @@ +{{ $langButtonSize := "w-4 h-4" }} + +{{- $lang := .Site.Language.Lang -}} +{{- $switch := dict + "en" (dict "url" "/zh/" "label" "ZH" "title" "查看中文博客") + "zh" (dict "url" "/en/" "label" "EN" "title" "View English Blog") -}} +{{- $entry := index $switch $lang -}} +<a + href="{{ $entry.url }}" + class="rd-full text-center hover:no-underline {{ $langButtonSize }} + bg-neutral/10 border-1 border-[var(--text-color)] border-solid + bg-[var(--block-background-color)] + flex items-center justify-center" + title="{{ $entry.title }}" +> + <span class="text-size-[0.5rem] font-extrabold">{{ $entry.label }}</span> +</a> diff --git a/layouts/_partials/header/other-navigation.html b/layouts/_partials/header/other-navigation.html index 13cacc5..7fad2bb 100644 --- a/layouts/_partials/header/other-navigation.html +++ b/layouts/_partials/header/other-navigation.html @@ -1,30 +1,4 @@ -{{ $langButtonSize := "w-4 h-4" }} - <div class="flex gap-2 pr-2"> - <!-- theme switch --> - <label for="theme-select" class="hidden">colorscheme</label> - <select id="theme-select" name="theme" - aria-label="Switch colorscheme" - class="bg-neutral/10 border-1 border-[var(--text-color)] border-solid rd text-[var(--text-color)] font-serif text-size-[0.5rem] font-extrabold"> - {{ $switches := slice "auto" "light" "dark" }} - {{ range $switches }} - <option value="{{ . }}">{{ T (printf "theme.%s" .) }}</option> - {{ end }} - </select> - <!-- language switch --> - {{- $lang := .Site.Language.Lang -}} - {{- $switch := dict - "en" (dict "url" "/zh/" "label" "ZH" "title" "查看中文博客") - "zh" (dict "url" "/en/" "label" "EN" "title" "View English Blog") -}} - {{- $entry := index $switch $lang -}} - <a - href="{{ $entry.url }}" - class="rd-full text-center hover:no-underline {{ $langButtonSize }} - bg-neutral/10 border-1 border-[var(--text-color)] border-solid - bg-[var(--block-background-color)] - flex items-center justify-center" - title="{{ $entry.title }}" - > - <span class="text-size-[0.5rem] font-extrabold">{{ $entry.label }}</span> - </a> + {{ partial "header/theme-switch" . }} + {{ partial "header/lang-switch" . }} </div> diff --git a/layouts/_partials/header/theme-switch.html b/layouts/_partials/header/theme-switch.html new file mode 100644 index 0000000..dd2026a --- /dev/null +++ b/layouts/_partials/header/theme-switch.html @@ -0,0 +1,9 @@ +<label for="theme-select" class="hidden">colorscheme</label> +<select id="theme-select" name="theme" + aria-label="Switch colorscheme" + class="bg-neutral/10 border-1 border-[var(--text-color)] border-solid rd text-[var(--text-color)] font-serif text-size-[0.5rem] font-extrabold"> +{{ $switches := slice "auto" "light" "dark" }} +{{ range $switches }} + <option value="{{ . }}">{{ T (printf "theme.%s" .) }}</option> +{{ end }} +</select> |
