Skip to content

Commit c322d3d

Browse files
Coderandreasgriffin
authored andcommitted
Fix top nav active state matching
1 parent 4c00ca5 commit c322d3d

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

layouts/partials/header/header.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@
2727
<div class="collapse navbar-collapse" id="navbarSupportedContent">
2828
<ul class="menu-main navbar-nav me-auto mb-2 mb-lg-0">
2929
{{- $current := . -}}
30-
{{- $section := $current.Section -}}
30+
{{- $currentPath := strings.TrimSuffix "/" $current.RelPermalink -}}
3131
{{ range .Site.Menus.main -}}
3232
{{- $active := or ($current.IsMenuCurrent "main" .) ($current.HasMenuCurrent "main" .) -}}
33-
{{- $active = or $active (eq .Name $current.LinkTitle) -}}
34-
{{- $active = or $active (and (eq .Name ($section | humanize)) (eq $current.Section $section)) -}}
35-
{{- $active = or $active (and (eq .Identifier ($section | humanize)) (eq $current.Section $section)) -}}
36-
{{- $active = or $active (and (eq .Name "Blog") (eq $current.Section "blog" "contributors")) -}}
33+
{{- $menuPath := strings.TrimSuffix "/" (.URL | relLangURL) -}}
34+
{{- $active = or $active (eq $menuPath $currentPath) -}}
3735
{{ if .HasChildren }}
3836
<li class="nav-item dropdown">
3937
<a class="nav-link dropdown-toggle" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">

0 commit comments

Comments
 (0)