docs-sidebar.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <nav class="collapse bd-links" id="bd-docs-nav" aria-label="Docs navigation">
  2. {{- $url := split .Permalink "/" -}}
  3. {{- $page_slug := index $url (sub (len $url) 2) -}}
  4. <ul class="list-unstyled mb-0 py-3 pt-md-1">
  5. {{- range $group := .Site.Data.sidebar -}}
  6. {{- $link := $group.title -}}
  7. {{- $link_slug := $link | urlize -}}
  8. {{- if $group.pages -}}
  9. {{- $link = index $group.pages 0 -}}
  10. {{- $link_slug = $link.title | urlize -}}
  11. {{- end -}}
  12. {{- $group_slug := $group.title | urlize -}}
  13. {{- $is_active_group := eq $.Page.Params.group $group_slug -}}
  14. {{- if $group.pages }}
  15. <li class="mb-1">
  16. <button class="btn d-inline-flex align-items-center rounded{{ if not $is_active_group }} collapsed{{ end }}" data-bs-toggle="collapse" data-bs-target="#{{ $group_slug }}-collapse" aria-expanded="{{ $is_active_group }}"{{ if $is_active_group }} aria-current="true"{{ end }}>
  17. {{ $group.title }}
  18. </button>
  19. <div class="collapse{{ if $is_active_group }} show{{ end }}" id="{{ $group_slug }}-collapse">
  20. <ul class="list-unstyled fw-normal pb-1 small">
  21. {{- range $doc := $group.pages -}}
  22. {{- $doc_slug := $doc.title | urlize -}}
  23. {{- $is_active := and $is_active_group (eq $page_slug $doc_slug) -}}
  24. {{- $href := printf "/docs/%s/%s/%s/" $.Site.Params.docs_version $group_slug $doc_slug }}
  25. <li><a href="{{ $href }}" class="d-inline-flex align-items-center rounded{{ if $is_active }} active{{ end }}"{{ if $is_active }} aria-current="page"{{ end }}>{{ $doc.title }}</a></li>
  26. {{- end }}
  27. </ul>
  28. </div>
  29. </li>
  30. {{- else }}
  31. <li class="my-3 mx-4 border-top"></li>
  32. <li>
  33. <a href="/docs/{{ $.Site.Params.docs_version }}/{{ $group_slug }}/" class="d-inline-flex align-items-center rounded{{ if $is_active_group }} active{{ end }}"{{ if $is_active_group }} aria-current="page"{{ end }}>
  34. {{ $group.title }}
  35. </a>
  36. </li>
  37. {{- end }}
  38. {{- end }}
  39. </ul>
  40. </nav>