diff options
author | Kris - The Coding Unicorn <47773700+guidemetothemoon@users.noreply.github.com> | 2022-05-13 21:46:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-13 21:46:45 +0300 |
commit | 1959fa6d400511da65044c29f1bc7c7030a31ca6 (patch) | |
tree | 632d23f8f0bfdb5a26b765a8a240ffbb2ec3d069 | |
parent | ec5066bdb57e8927150cb9e1b37ad0cedb047716 (diff) |
fix: incorrect display of submenu items when multiple menu dropdowns are implemented (#354)
Close #352
Co-authored-by: Alexander Bilz <mail@alexbilz.com>
-rw-r--r-- | layouts/partials/navbar.html | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/layouts/partials/navbar.html b/layouts/partials/navbar.html index 6dec190..d0de29a 100644 --- a/layouts/partials/navbar.html +++ b/layouts/partials/navbar.html @@ -15,33 +15,30 @@ <nav class="nav"> <ul class="nav__list" id="navMenu"> {{ $url := .RelPermalink }} - {{ $current := . }} - {{ range .Site.Menus.main }} - {{ $active := eq $url .URL }} - {{ if .HasChildren }} + {{ range $menuId, $menuItem := .Site.Menus.main }} + {{ $active := eq $url $menuItem.URL }} + {{ if $menuItem.HasChildren }} + <li class="nav__list-item"> <div class="optionswitch"> - <input class="optionswitch__picker" type="checkbox" id="menuoptionpicker" hidden /> + <input class="optionswitch__picker" type="checkbox" id="{{ $menuId }}" hidden /> {{ $labelClass := "optionswitch__label" }} - {{ range .Children }} + {{ range $menuItem.Children }} {{ if eq $url .URL }} {{ $labelClass = "optionswitch__label nav__link--active" }} - {{ end }} - {{ end }} - - <label class="{{ $labelClass }}" for="menuoptionpicker" - >{{ .Name }} <i class="fa fa-angle-down" aria-hidden="true"></i + <label class="{{ $labelClass }}" for="{{ $menuId }}" + >{{ $menuItem.Name }} <i class="fa fa-angle-down" aria-hidden="true"></i ></label> <div class="optionswitch__triangle"></div> <ul class="optionswitch__list"> - {{ range .Children }} + {{ range $menuItem.Children }} <li class="optionswitch__list-item"> <a href="{{ .URL }}" @@ -72,7 +69,7 @@ {{ end }} title="{{ .Title }}" - >{{ .Name }}</a + >{{ $menuItem.Name }}</a > </li> |