Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect display of submenu items when multiple menu dropdowns are implemented #354

Merged
23 changes: 10 additions & 13 deletions layouts/partials/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down Expand Up @@ -72,7 +69,7 @@

{{ end }}
title="{{ .Title }}"
>{{ .Name }}</a
>{{ $menuItem.Name }}</a
>
</li>

Expand Down