menu-filetree.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <ul>
  2. <li>{{ template "book-section" (dict "Section" .Site.Sections "CurrentPage" $.Permalink) }}</li>
  3. </ul>
  4. {{ define "book-section" }} <!-- Single section of menu (recursive) -->
  5. <ul {{ if .Expanded }}class="expanded"{{ end }}>
  6. {{ range (.Section.ByParam "Title").ByParam "Weight" }}
  7. {{ if ne .Title "Search Index" }}
  8. {{ if and (eq .Kind "section") (or (gt (len .Pages) 0) (gt (len .Sections) 0) ) }}
  9. <li class="section">
  10. {{ $expanded := in $.CurrentPage .Permalink }}
  11. <div class="section-link">
  12. <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 section-icon {{ if $expanded}}expanded{{ end }}">
  13. <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
  14. </svg>
  15. {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
  16. </div>
  17. {{ template "book-section" (dict "Section" .Pages "CurrentPage" $.CurrentPage "Expanded" $expanded) }}
  18. </li>
  19. {{ else }}
  20. <li>
  21. {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
  22. </li>
  23. {{ end }}
  24. {{end }}
  25. {{ end }}
  26. </ul>
  27. {{ end }}
  28. {{ define "book-page-link" }}
  29. {{- with .Page -}}
  30. <a href="{{ .RelPermalink }}" {{- if eq $.CurrentPage .Permalink }} class="text-blue-700 active"{{ end }}>
  31. {{- template "title" . -}}
  32. </a>
  33. {{- end -}}
  34. {{ end }}