fix docs menu depth collapsing

This commit is contained in:
a 2022-12-11 18:48:40 -06:00
parent 317e9651c9
commit 73d11f00b8

View file

@ -9,64 +9,45 @@
<a id="menu" href="#top">Skip menu</a> <a id="menu" href="#top">Skip menu</a>
{{ $currentPage := . }} {{ $currentPage := . }}
{{ range .Site.Menus.docs }} {{ range .Site.Menus.docs }}
{{ $active := or ($currentPage.IsMenuCurrent "docs" .) (eq $currentPage.Section .Identifier)}} {{ $active := or ($currentPage.IsMenuCurrent "docs" .) (eq $currentPage.Section .Identifier)}}
{{ if .HasChildren }} <details class='section-title{{- if $active }} active{{ end -}}' {{- if $active }} open{{ end -}}>
<details {{ if .HasChildren }}
class='section-title <summary href="{{ .URL | relLangURL }}">
{{- if $active }} active{{ end -}} {{ .Pre }}<span>{{ .Name }}</span>{{ .Post }}
' </summary>
{{- if $active }} open{{ end -}}> <ul class="sub-menu" data-depth=1>
<summary href="{{ .URL | relLangURL }}">
{{ .Pre }}
<span>{{ .Name }}</span>
{{ .Post }}
</summary>
<ul class="sub-menu">
{{ range .Children }} {{ range .Children }}
{{ if .HasChildren}} {{ if .HasChildren}}
<li <li class='{{- if $active }} active{{ end -}}'>
class='{{- if $active }} active{{ end -}}'> <a href="{{ .URL | relLangURL }}">
<a href="{{ .URL | relLangURL }}"> {{ .Pre }}<span>{{ .Name }}</span>{{ .Post }}
{{ .Pre }} </a>
<span>{{ .Name }}</span> <ul class="sub-menu" data-depth=2>
{{ .Post }}
</a>
<ul class="sub-menu">
{{ range .Children }} {{ range .Children }}
<li <li class='{{- if $active }} active{{ end -}}'>
class='{{- if $active }} active{{ end -}}'>
<a href="{{ .URL | relLangURL }}"> <a href="{{ .URL | relLangURL }}">
{{ .Pre }} {{ .Pre }}<span>{{ .Name }}</span>{{ .Post }}
<span>{{ .Name }}</span>
{{ .Post }}
</a> </a>
</li>
{{ end }}{{/* range .Children (subsubmenu) */}}
</ul>
{{ else }}{{/* not .HasChildren (subsubmenu) */}}
<li class='{{- if $active }} active{{ end -}}'>
<a href="{{ .URL | relLangURL }}">
{{ .Pre }}<span>{{ .Name }}</span>{{ .Post }}
</a>
</li> </li>
{{ end }} {{ end }}{{/* range .Children */}}
</ul> {{ end }}
</details> </ul>
{{ else }} {{ else }}
<li <li class='{{- if $active }} active{{ end -}}'>
class='{{- if $active }} active{{ end -}}'>
<a href="{{ .URL | relLangURL }}"> <a href="{{ .URL | relLangURL }}">
{{ .Pre }} {{ .Pre }}<span>{{ .Name }}</span>{{ .Post }}
<span>{{ .Name }}</span>
{{ .Post }}
</a> </a>
</li> </li>
{{ end }} {{ end }}
{{ end }} </details>
</ul>
</li>
{{ else }}
<li
class='{{- if $active }} active{{ end -}}'>
<a href="{{ .URL | relLangURL }}">
{{ .Pre }}
<span>{{ .Name }}</span>
{{ .Post }}
</a>
</li>
{{ end }}
{{ end }} {{ end }}
</ul> </ul>
</div> </div>