diff options
Diffstat (limited to 'themes/danix-xyz-hacker/layouts/partials/hamburger-menu.html')
| -rw-r--r-- | themes/danix-xyz-hacker/layouts/partials/hamburger-menu.html | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/themes/danix-xyz-hacker/layouts/partials/hamburger-menu.html b/themes/danix-xyz-hacker/layouts/partials/hamburger-menu.html index c22981b..ee80d20 100644 --- a/themes/danix-xyz-hacker/layouts/partials/hamburger-menu.html +++ b/themes/danix-xyz-hacker/layouts/partials/hamburger-menu.html @@ -38,14 +38,25 @@ <div class="text-sm text-text-dim mb-3">{{ i18n "language" }}</div> <div class="flex gap-2"> {{ $currentLang := .Page.Language }} + {{ $currentPath := .RelPermalink }} {{ range .Site.Languages }} {{ $langCode := .Lang }} {{ $langName := .LanguageName }} {{ $current := eq $langCode $currentLang }} - {{ $prefix := cond (eq $langCode "en") "" (printf "/%s" $langCode) }} + <!-- Build the translated URL by replacing language prefix --> + {{ $url := $currentPath }} + {{ if eq $langCode "en" }} + {{ if hasPrefix $currentPath "/it/" }} + {{ $url = strings.TrimPrefix "/it" $currentPath }} + {{ end }} + {{ else }} + {{ if not (hasPrefix $currentPath "/it/") }} + {{ $url = printf "/it%s" $currentPath }} + {{ end }} + {{ end }} <a data-lang-switch="{{ $langCode }}" - href="{{ $prefix }}/" + href="{{ $url }}" class="flex-1 py-2 px-3 text-center rounded transition-colors {{ if $current }}bg-accent text-white{{ else }}bg-surface hover:bg-surface/80{{ end }}" > {{ $langName }} |
