From 23c84e124cdf46e6d963e724e83ed1338dc5934b Mon Sep 17 00:00:00 2001 From: Xin Date: Fri, 10 Nov 2023 12:45:44 -0500 Subject: [PATCH] fix: navbar url for multi-lang site (#193) * fix: image URL in feature card * fix: use relLangURL of pageRef for navbar entries --- layouts/partials/navbar.html | 13 ++++++++++--- layouts/shortcodes/hextra/feature-card.html | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/layouts/partials/navbar.html b/layouts/partials/navbar.html index 0a49630..cca829c 100644 --- a/layouts/partials/navbar.html +++ b/layouts/partials/navbar.html @@ -32,10 +32,17 @@ {{- if eq .Params.type "search" -}} {{- partial "search.html" (dict "params" .Params) -}} {{- else -}} - {{- $external := strings.HasPrefix .URL "http" -}} + {{- $link := .URL -}} + {{- $external := strings.HasPrefix $link "http" -}} + {{- with .PageRef -}} + {{- if hasPrefix . "/" -}} + {{- $link = relLangURL (strings.TrimPrefix "/" .) -}} + {{- end -}} + {{- end -}} + {{/* Display icon menu item */}} {{- if .Params.icon -}} - + {{- partial "utils/icon.html" (dict "name" .Params.icon "attributes" "height=24") -}} {{ or (T .Identifier) .Name | safeHTML }} @@ -44,7 +51,7 @@ {{- $activeClass := cond $active "font-medium" "text-gray-600 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200" -}}