From 5d720fc7fe2977401b8bfd29e94f18954559ba6b Mon Sep 17 00:00:00 2001 From: Will Faught Date: Sun, 19 Mar 2023 20:43:40 -0700 Subject: [PATCH] Fix active menu for custom permalinks --- layouts/partials/paige/menu.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/layouts/partials/paige/menu.html b/layouts/partials/paige/menu.html index e65bdee4..36c7beec 100644 --- a/layouts/partials/paige/menu.html +++ b/layouts/partials/paige/menu.html @@ -30,7 +30,10 @@ {{ range site.Menus.main }} {{ $pagepath := strings.TrimPrefix $basepath $.RelPermalink }} {{ $menupath := strings.TrimPrefix $basepath .URL }} - {{ $active := or (and (eq $menupath "/") (eq $pagepath "/")) (and (ne $menupath "/") (hasPrefix $pagepath $menupath)) }} + {{ $home := (and (eq $menupath "/") (eq $pagepath "/")) }} + {{ $menuprefix := (and (ne $menupath "/") (hasPrefix $pagepath $menupath)) }} + {{ $sectionprefix := (and (ne $menupath "/") (hasPrefix $menupath (printf "/%s/" $page.Section))) }} + {{ $active := or $home $menuprefix $sectionprefix }} {{ .Name }} {{ end }}