menu-filetree.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <ul>
  2. <li>
  3. <ul><li><a href="/getting-started" {{- if eq .Page.Title "Getting Started" }} class="text-blue-700 active"{{ end }}>
  4. Getting Started
  5. </a></li></ul>
  6. </li>
  7. <li>{{ template "book-section" (dict "Section" .Site.Sections "CurrentPage" $.Permalink) }}</li>
  8. </ul>
  9. {{ define "book-section" }} <!-- Single section of menu (recursive) -->
  10. <ul {{ if .Expanded }}class="expanded"{{ end }}>
  11. {{ range (.Section.ByParam "Title").ByParam "Weight" }}
  12. {{ if ne .Title "Search Index" }}
  13. {{ if and (eq .Kind "section") (or (gt (len .Pages) 0) (gt (len .Sections) 0) ) }}
  14. <li class="section">
  15. {{ $expanded := in $.CurrentPage .Permalink }}
  16. <div class="section-link">
  17. <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 }}">
  18. <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 15.75l7.5-7.5 7.5 7.5" />
  19. </svg>
  20. {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
  21. </div>
  22. {{ template "book-section" (dict "Section" .Pages "CurrentPage" $.CurrentPage "Expanded" $expanded) }}
  23. </li>
  24. {{ else }}
  25. <li>
  26. {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
  27. </li>
  28. {{ end }}
  29. {{end }}
  30. {{ end }}
  31. </ul>
  32. {{ end }}
  33. {{ define "book-page-link" }}
  34. {{- with .Page -}}
  35. <a href="{{ .RelPermalink }}" {{- if eq $.CurrentPage .Permalink }} class="text-blue-700 active"{{ end }}>
  36. {{- template "title" . -}}
  37. </a>
  38. {{- end -}}
  39. {{ end }}