From 05e28a716df8b7983c39375992fa9beea2d9f1bf Mon Sep 17 00:00:00 2001 From: Xin <5097752+imfing@users.noreply.github.com> Date: Sat, 24 Jan 2026 12:27:37 +0000 Subject: [PATCH] feat(navbar): enhance active link detection for multilingual section landing pages (#913) - Added logic to normalize trailing slashes for section landing pages in multilingual sites, improving the accuracy of active link detection in the navbar. - This enhancement ensures that the correct link is highlighted as active, providing a better user experience across different languages. --- layouts/_partials/navbar-link.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/layouts/_partials/navbar-link.html b/layouts/_partials/navbar-link.html index 57f4186..df6844a 100644 --- a/layouts/_partials/navbar-link.html +++ b/layouts/_partials/navbar-link.html @@ -5,6 +5,14 @@ {{- $external := .external -}} {{- $active := or ($currentPage.HasMenuCurrent "main" $item) ($currentPage.IsMenuCurrent "main" $item) -}} +{{- /* Additional check for section landing pages in multilingual sites (normalize trailing slashes) */ -}} +{{- if and (not $active) $link -}} + {{- $currentPath := strings.TrimSuffix "/" $currentPage.RelPermalink -}} + {{- $linkPath := strings.TrimSuffix "/" $link -}} + {{- if eq $currentPath $linkPath -}} + {{- $active = true -}} + {{- end -}} +{{- end -}} {{- $activeClass := cond $active "hx:font-medium" "hx:text-gray-600 hx:hover:text-gray-800 hx:dark:text-gray-400 hx:dark:hover:text-gray-200" -}} {{- if $item.HasChildren -}}