Toevoegen subitems aan menu's en eenduidige structuur van hoofditems

This commit is contained in:
Michael Boelen 2023-05-17 11:43:44 +02:00
parent 0fb9dabfef
commit 706e8f4627
3 changed files with 27 additions and 4 deletions

View file

@ -14,10 +14,10 @@
<ul class="menus menu">
{{ $currentPage := . }}
{{ range .Site.Menus.main }}
{{ if .Children }}
{{ $.Scratch.Set "counter" (add ($.Scratch.Get "counter") 1) }}
{{ if .Children }}
<li>
<button type="button" aria-haspopup="true" aria-expanded="true" aria-controls="dropdown{{ $.Scratch.Get "counter" }}">{{ .Name }}<span class="arrow"></span></button>
<button type="button" aria-haspopup="true" aria-expanded="true" aria-controls="dropdown{{ $.Scratch.Get "counter" }}"><a href="{{ .URL }}">{{ .Name }}</a><!-- <span class="arrow"></span>--></button>
<ul class="dropdown" id="dropdown{{ $.Scratch.Get "counter" }}">
{{ range .Children }}
<li><a href="{{ .URL }}">{{ .Name }}</a></li>
@ -25,7 +25,7 @@
</ul>
</li>
{{ else }}
<li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}"><a href="{{ .URL }}">{{ .Name }}</a></li>
<li><button type="button" aria-haspopup="true" aria-expanded="true" aria-controls="dropdown{{ $.Scratch.Get "counter" }}"><a href="{{ .URL }}">{{ .Name }}</a></button></li>
{{ end }}
{{ end }}
</ul>