From 5981551998254561e1731f4c1f6e978a643296e2 Mon Sep 17 00:00:00 2001 From: Alex Hua Date: Sat, 8 Apr 2023 17:21:38 +0800 Subject: [PATCH] feat: auto-switch site lang when homepage visited 1. auto-switch site lang according to setting from sidebar or browser lang settings, when home page is visited. 2. save sidebar lang setting to local storage. --- layouts/_default/baseof.html | 1 + layouts/partials/head/autoLang.html | 31 +++++++++++++++++++++++++++++ layouts/partials/sidebar/left.html | 4 ++-- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 layouts/partials/head/autoLang.html diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 83fdaa3..dccb069 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -6,6 +6,7 @@ {{- partial "head/colorScheme" . -}} + {{- partial "head/autoLang" . -}} {{/* The container is wider when there's any activated widget */}} {{- $hasWidget := false -}} diff --git a/layouts/partials/head/autoLang.html b/layouts/partials/head/autoLang.html new file mode 100644 index 0000000..1bbbbb1 --- /dev/null +++ b/layouts/partials/head/autoLang.html @@ -0,0 +1,31 @@ +{{ if .Site.IsMultiLingual }} + +{{ end }} diff --git a/layouts/partials/sidebar/left.html b/layouts/partials/sidebar/left.html index 32e5a12..50c1c4e 100644 --- a/layouts/partials/sidebar/left.html +++ b/layouts/partials/sidebar/left.html @@ -80,9 +80,9 @@ {{ with .Site.Home.AllTranslations }}
  • {{ partial "helper/icon" "language" }} - {{ range . }} - + {{ end }}