single-menu.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <div class="menu">
  2. <h6 class="menu__label">
  3. {{ if .IsHome }}
  4. {{ .Site.Title }}
  5. {{ else }}
  6. {{ .Type }}
  7. {{ end }}
  8. </h6>
  9. <ul>
  10. {{ $currentURL := .Permalink }}
  11. {{ range (.Site.GetPage "section" .Type).Pages }}
  12. {{ $sectionName1 := index (last 1 (split (delimit (split .Permalink "/") "," "") ",")) 0 }}
  13. {{ $sectionName2 := index (last 2 (split (delimit (split $currentURL "/") "," "") ",")) 0 }}
  14. {{ if .Params.Collapsible }}
  15. <span class="menu__title--collapse {{ if and (in $currentURL .Permalink) (eq $sectionName1 $sectionName2) }}active{{ end }}">
  16. {{ .Title }}
  17. <span class="menu__title--icon {{ if and (in $currentURL .Permalink) (eq $sectionName1 $sectionName2) }}{{ if eq ($.Param "languagedir") "rtl" }}downrtl{{ else }}down{{ end }}{{ else }}right{{ end }}">
  18. {{ if eq ($.Param "languagedir") "rtl" }}
  19. {{ partial "svgs/arrow-left.svg" (dict "width" 22 "height" 22) }}
  20. {{ else }}
  21. {{ partial "svgs/arrow-right.svg" (dict "width" 22 "height" 22) }}
  22. {{ end }}
  23. </span>
  24. </span>
  25. <ul class="menu__list {{ if and (in $currentURL .Permalink) (eq $sectionName1 $sectionName2) }}active{{ end }}">
  26. {{ range .Pages.ByWeight }}
  27. {{ $lastUrlElement1 := index (last 1 (split (delimit (split .Permalink "/") "," "") ",")) 0 }}
  28. {{ $lastUrlElement2 := index (last 1 (split (delimit (split $currentURL "/") "," "") ",")) 0 }}
  29. <li>
  30. <a href="{{ .Permalink }}" class="menu__title {{ if and (eq $lastUrlElement1 $lastUrlElement2) (eq $sectionName1 $sectionName2) }}active{{ end }}">{{ .Title }}</a>
  31. </li>
  32. {{ end }}
  33. </ul>
  34. {{ else }}
  35. {{ $lastUrlElement1 := index (last 1 (split (delimit (split .Permalink "/") "," "") ",")) 0 }}
  36. {{ $lastUrlElement2 := index (last 1 (split (delimit (split $currentURL "/") "," "") ",")) 0 }}
  37. <li>
  38. <a href="{{ .Permalink }}" class="menu__title {{ if in $lastUrlElement1 $lastUrlElement2 }}active{{ end }}">{{ .Title }}</a>
  39. </li>
  40. {{ end }}
  41. {{ end }}
  42. </ul>
  43. </div>