diff options
author | Guillermo Guerrero Ibarra <wolf.fox1985@gmail.com> | 2021-08-13 01:28:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-13 01:28:33 +0300 |
commit | 22efcc0cc397ebdaa7d4f3543608b14316a88698 (patch) | |
tree | 405251be9306f86ee9e327cd2eafa1d4a8f72377 | |
parent | cabdeac091016efa9cf0ec9b2483c0eacff48989 (diff) |
Fixed menu highlight. (#313)1.2.2
Co-authored-by: Guillermo Guerrero Ibarra <guillermo.guerrero@deliveroo.co.uk>
-rw-r--r-- | layouts/partials/nav.html | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index 3b98707..8142469 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -19,12 +19,27 @@ <div class="navbar-collapse collapse" id="navigation"> <ul class="nav navbar-nav navbar-right"> {{ $current := . }} - {{ $topLevel := replace .URL "/" "" }} + {{ range .Site.Menus.main.ByWeight }} + {{ $topLevel := replace .URL "/" "" }} {{ $active := "" }} - {{ if eq $current.RelPermalink .URL | or (eq $current.Type $topLevel) | or (and (eq (default (trim .URL "/") .Identifier) "blog") (in (slice "taxonomy" "taxonomyTerm") $current.Kind)) }} + + {{ if eq $current.RelPermalink .URL }} {{ $active = "active" }} {{ end }} + + {{ if eq $current.Type $topLevel }} + {{ $active = "active" }} + {{ end }} + + {{ if and (or (eq $current.URL .URL) (eq "term" $current.Kind)) (in (slice "page" "term") $current.Kind) }} + {{ range (split .URL "/") }} + {{ if eq "blog" . }} + {{ $active = "active" }} + {{ end }} + {{ end }} + {{ end }} + {{ if .HasChildren }} <!-- Check if the first child marks a menu section identifier --> {{ $hasSections := (hasPrefix (index .Children 0).Identifier "section.") }} |