You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

menu-filetree.html 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!-- Put configured sections list to .Scratch -->
  2. {{ template "book-get-root-section" . }}
  3. {{- range .Scratch.Get "BookSections" -}}
  4. {{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }}
  5. {{- end -}}
  6. {{ define "book-section" }} <!-- Single section of menu (recursive) -->
  7. <ul>
  8. {{ range .Section.Sections }}
  9. <li {{- if .Params.bookflatsection}} class="flat-section" {{ end }}>
  10. {{- if .Content -}}
  11. {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
  12. {{- else -}}
  13. {{- template "title" . -}}
  14. {{- end -}}
  15. {{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }}
  16. </li>
  17. {{ end }}
  18. {{ range .Section.Pages }}
  19. {{- if .Content -}}
  20. <li>
  21. {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
  22. </li>
  23. {{- end -}}
  24. {{ end }}
  25. </ul>
  26. {{ end }}
  27. {{ define "book-page-link" }}
  28. {{- with .Page -}}
  29. <a href="{{ .RelPermalink }}" {{- if eq $.CurrentPage .Permalink }} class="active"{{ end }}>
  30. {{- template "title" . -}}
  31. </a>
  32. {{- end -}}
  33. {{ end }}
  34. {{ define "book-get-root-section" }}
  35. <!-- Complex logic to guess page title without .Title specified -->
  36. {{ $bookSection := default "docs" .Site.Params.BookSection }}
  37. {{ if eq $bookSection "*" }}
  38. {{ .Scratch.Set "BookSections" .Site.Sections }}
  39. {{ else }}
  40. {{ $bookSections := where .Site.Sections "Section" $bookSection }}
  41. {{ .Scratch.Set "BookSections" $bookSections }}
  42. {{ end }}
  43. {{ end }}