menu-filetree.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {{ $current := . }}
  2. {{ template "tree-nav" dict "sect" .Site.Home.Sections "current" $current }}
  3. <!-- templates -->
  4. {{ define "tree-nav" }}
  5. {{ $current := .current }}
  6. <ul class="gdoc-nav__list">
  7. {{ $sortBy := (default "title" .current.Site.Params.geekdocFileTreeSortBy | lower) }}
  8. {{ range .sect.GroupBy "Weight" }}
  9. {{ $rangeBy := .ByTitle }}
  10. {{ if eq $sortBy "title" }}
  11. {{ $rangeBy = .ByTitle }}
  12. {{ else if eq $sortBy "linktitle" }}
  13. {{ $rangeBy = .ByLinkTitle }}
  14. {{ else if eq $sortBy "date" }}
  15. {{ $rangeBy = .ByDate }}
  16. {{ else if eq $sortBy "publishdate" }}
  17. {{ $rangeBy = .ByPublishDate }}
  18. {{ else if eq $sortBy "expirydate" }}
  19. {{ $rangeBy = .ByExpiryDate }}
  20. {{ else if eq $sortBy "lastmod" }}
  21. {{ $rangeBy = .ByLastmod }}
  22. {{ else if eq $sortBy "title_reverse" }}
  23. {{ $rangeBy = .ByTitle.Reverse }}
  24. {{ else if eq $sortBy "linktitle_reverse" }}
  25. {{ $rangeBy = .ByLinkTitle.Reverse }}
  26. {{ else if eq $sortBy "date_reverse" }}
  27. {{ $rangeBy = .ByDate.Reverse }}
  28. {{ else if eq $sortBy "publishdate_reverse" }}
  29. {{ $rangeBy = .ByPublishDate.Reverse }}
  30. {{ else if eq $sortBy "expirydate_reverse" }}
  31. {{ $rangeBy = .ByExpiryDate.Reverse }}
  32. {{ else if eq $sortBy "lastmod_reverse" }}
  33. {{ $rangeBy = .ByLastmod.Reverse }}
  34. {{ end }}
  35. {{ range $rangeBy }}
  36. {{ if not .Params.geekdocHidden }}
  37. {{ $numberOfPages := (add (len .Pages) (len .Sections)) }}
  38. {{ $isParent := and (ne $numberOfPages 0) (not .Params.geekdocFlatSection) }}
  39. {{ $isCurrent := eq $current . }}
  40. {{ $isAncestor := .IsAncestor $current }}
  41. {{ $id := substr (sha1 .Permalink) 0 8 }}
  42. {{ $doCollapse := and $isParent (or .Params.geekdocCollapseSection (default false .Site.Params.geekdocCollapseAllSections)) }}
  43. <li>
  44. <input
  45. type="checkbox"
  46. {{ if $doCollapse }}
  47. class="gdoc-nav__toggle" id="{{ printf "navtree-%s" $id }}"
  48. {{ if or $isCurrent $isAncestor }}checked{{ end }}
  49. {{ else }}
  50. class="hidden"
  51. {{ end }}
  52. />
  53. <label
  54. {{ if $doCollapse }}
  55. for="{{ printf "navtree-%s" $id }}" class="flex justify-between align-center"
  56. {{ end }}
  57. >
  58. {{ if or .Content .Params.geekdocFlatSection }}
  59. <span class="flex">
  60. <a
  61. href="{{ .RelPermalink }}"
  62. class="gdoc-nav__entry{{- if eq $current . }}
  63. {{- printf " is-active" }}
  64. {{- end }}"
  65. >
  66. {{ partial "utils/title" . }}
  67. </a>
  68. </span>
  69. {{ else }}
  70. <span class="flex">{{ partial "utils/title" . }}</span>
  71. {{ end }}
  72. {{ if $doCollapse }}
  73. <svg class="gdoc-icon toggle gdoc_keyboard_arrow_left">
  74. <use xlink:href="#gdoc_keyboard_arrow_left"></use>
  75. </svg>
  76. <svg class="gdoc-icon toggle gdoc_keyboard_arrow_down">
  77. <use xlink:href="#gdoc_keyboard_arrow_down"></use>
  78. </svg>
  79. {{ end }}
  80. </label>
  81. {{ if $isParent }}
  82. {{ template "tree-nav" dict "sect" .Pages "current" $current }}
  83. {{ end }}
  84. </li>
  85. {{ end }}
  86. {{ end }}
  87. {{ end }}
  88. </ul>
  89. {{ end }}