portails/layouts/partials/sidebar/auto-collapsible-menu.html

57 lines
3.2 KiB
HTML

<!-- Auto collapsible section menu -->
<ul class="list-unstyled collapsible-sidebar">
{{ $currentPage := . -}}
{{ $section := $currentPage.Section -}}
{{ range (where .Site.Sections "Section" "in" $section) }}
{{ range .Sections.ByWeight.Reverse }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
<li class="mb-1">
<button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#section-{{ md5 .Title }}" aria-expanded="{{ if $active }}true{{ else }}false{{ end }}">
{{ .Title }}
</button>
<div class="collapse{{ if $active }} show{{ end }}" id="section-{{ md5 .Title }}">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
{{ range .Pages }}
{{ if .IsNode }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
<li class="my-1 ms-3">
<button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#section-{{ md5 .Title }}" aria-expanded="{{ if $active }}true{{ else }}false{{ end }}">
{{ .Title }}
</button>
<div class="collapse{{ if $active }} show{{ end }}" id="section-{{ md5 .Title }}">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
{{ range .Pages }}
{{ if .IsNode }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
<li class="my-1 ms-3">
<button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#section-{{ md5 .Title }}" aria-expanded="{{ if $active }}true{{ else }}false{{ end }}">
{{ .Title }}
</button>
<div class="collapse{{ if $active }} show{{ end }}" id="section-{{ md5 .Title }}">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
{{ range .Pages }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
<li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
</div>
</li>
{{ else }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
<li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
</ul>
</div>
</li>
{{ else }}
{{ $active := in $currentPage.RelPermalink .RelPermalink }}
<li><a class="docs-link rounded{{ if $active }} active{{ end }}" href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}
</ul>
</div>
</li>
{{ end }}
{{ end }}
</ul>