From 1959fa6d400511da65044c29f1bc7c7030a31ca6 Mon Sep 17 00:00:00 2001
From: Kris - The Coding Unicorn <47773700+guidemetothemoon@users.noreply.github.com>
Date: Fri, 13 May 2022 18:46:45 +0000
Subject: [PATCH] fix: incorrect display of submenu items when multiple menu dropdowns are implemented (#354)
---
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>
--
Gitblit v1.10.0