Skip to content

Commit 7203d8f

Browse files
committed
fix: 修复首页没有其他语言版本时,语言切换器仍显示的问题
1 parent 5d061e8 commit 7203d8f

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

layouts/_partials/language-switcher.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
{{ if .IsTranslated }}
1+
{{ $showSwitcher := .IsTranslated }}
2+
{{ if .IsHome }}
3+
{{ $showSwitcher = false }}
4+
{{ $translations := .AllTranslations }}
5+
{{ $hasAllHomeFiles := gt (len $translations) 1 }}
6+
{{ range $translations }}
7+
{{ if not .File }}
8+
{{ $hasAllHomeFiles = false }}
9+
{{ end }}
10+
{{ end }}
11+
{{ $showSwitcher = $hasAllHomeFiles }}
12+
{{ end }}
13+
14+
{{ if $showSwitcher }}
215
{{ $translations := .AllTranslations }}
316
<nav class="language-switcher" aria-label="{{ T "language.switcher" }}">
417
{{ range $translations }}

0 commit comments

Comments
 (0)