menu-bundle-np.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. {{ $current := . }}
  2. {{ $site := .Site }}
  3. {{ $current.Scratch.Set "prev" false }}
  4. {{ $current.Scratch.Set "getNext" false }}
  5. {{ $current.Scratch.Set "nextPage" false }}
  6. {{ $current.Scratch.Set "prevPage" false }}
  7. {{ template "menu-bundle-np" dict "sect" $.Site.Data.menu.main.main "current" $current "site" $site }}
  8. {{ define "menu-bundle-np" }}
  9. {{ $current := .current }}
  10. {{ $site := .site }}
  11. {{ range sort (default (seq 0) .sect) "weight" }}
  12. {{ $current.Scratch.Set "current" $current }}
  13. {{ $current.Scratch.Set "site" $site }}
  14. {{ $ref := default false .ref }}
  15. {{ if $ref }}
  16. {{ $site := $current.Scratch.Get "site" }}
  17. {{ $this := $site.GetPage .ref }}
  18. {{ $current := $current.Scratch.Get "current" }}
  19. {{ if reflect.IsMap .name }}
  20. {{ $current.Scratch.Set "refName" (index .name $site.Language.Lang) }}
  21. {{ else }}
  22. {{ $current.Scratch.Set "refName" .name }}
  23. {{ end }}
  24. {{ $name := $current.Scratch.Get "refName" }}
  25. {{ if $current.Scratch.Get "getNext" }}
  26. {{ $current.Scratch.Set "nextPage" (dict "name" $name "this" $this) }}
  27. {{ $current.Scratch.Set "getNext" false }}
  28. {{ end }}
  29. {{ if eq $current $this }}
  30. {{ $current.Scratch.Set "prevPage" ($current.Scratch.Get "prev") }}
  31. {{ $current.Scratch.Set "getNext" true }}
  32. {{ end }}
  33. {{ $current.Scratch.Set "prev" (dict "name" $name "this" $this) }}
  34. {{ end }}
  35. {{ $sub := default false .sub }}
  36. {{ if $sub }}
  37. {{ template "menu-bundle-np" dict "sect" $sub "current" ($current.Scratch.Get "current") "site" ($current.Scratch.Get "site") }}
  38. {{ end }}
  39. {{ end }}
  40. {{ end }}
  41. <span class="gdoc-page__nav">
  42. {{ with ($current.Scratch.Get "prevPage") }}
  43. <a
  44. class="gdoc-page__nav--prev flex align-center"
  45. href="{{ .this.RelPermalink }}"
  46. title="{{ .name }}"
  47. >
  48. <i class="gdoc-icon">gdoc_arrow_left_alt</i>
  49. {{ .name }}
  50. </a>
  51. {{ end }}
  52. </span>
  53. <span class="gdoc-page__nav">
  54. {{ with ($current.Scratch.Get "nextPage") }}
  55. <a
  56. class="gdoc-page__nav--next flex align-center"
  57. href="{{ .this.RelPermalink }}"
  58. title="{{ .name }}"
  59. >
  60. {{ .name }}
  61. <i class="gdoc-icon">gdoc_arrow_right_alt</i>
  62. </a>
  63. {{ end }}
  64. </span>