Commit ab558498 authored by Henk Verlinde's avatar Henk Verlinde
Browse files

setup: separate section menu logic from menu building

parent 3e384f39
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -74,10 +74,6 @@ docsRepoBranch = "master"
editPage = false
lastMod = false


mainSections = ["docs"]


[options]
  lazySizes = true
  clipBoard = true
@@ -93,5 +89,6 @@ mainSections = ["docs"]

[menu]
  [menu.section]
    auto = true
    auto = false
    collapsibleSidebar = true
    mainSections = ["docs", "tutorial"]
+8 −0
Original line number Diff line number Diff line
---
title: "Tutorial"
description: ""
date: 2022-01-25T14:40:56+01:00
lastmod: 2022-01-25T14:40:56+01:00
draft: false
images: []
---
+8 −0
Original line number Diff line number Diff line
---
title: "Lorem"
description: ""
date: 2022-01-25T14:41:21+01:00
lastmod: 2022-01-25T14:41:21+01:00
draft: false
images: []
---
+8 −0
Original line number Diff line number Diff line
---
title: "Ipsum"
description: ""
date: 2022-01-25T14:41:39+01:00
lastmod: 2022-01-25T14:41:39+01:00
draft: false
images: []
---
+56 −0
Original line number Diff line number Diff line
<!-- Auto collapsible section menu, multi level -->
<ul class="list-unstyled collapsible-sidebar">
  {{ $currentPage := . -}}
  {{ range (where .Site.Sections "Section" "in" site.Params.menu.section.mainSections) }}
    {{ range .Sections.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>
 No newline at end of file
Loading