menu-extra.html 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. {{ $current := .current }}
  2. {{ template "menu-extra" dict "sect" .source "current" $current "site" $current.Site "target" .target }}
  3. <!-- template -->
  4. {{ define "menu-extra" }}
  5. {{ $current := .current }}
  6. {{ $site := .site }}
  7. {{ $target := .target }}
  8. {{ $sect := .sect }}
  9. {{ range sort (default (seq 0) $sect) "weight" }}
  10. {{ if isset . "ref" }}
  11. {{ $this := $site.GetPage .ref }}
  12. {{ $isCurrent := eq $current $this }}
  13. {{ $icon := default false .icon }}
  14. {{ $name := .name }}
  15. {{ if reflect.IsMap .name }}
  16. {{ $name = (index .name $site.Language.Lang) }}
  17. {{ end }}
  18. {{ if not .icon }}
  19. {{ errorf "Missing 'icon' attribute in data file for '%s' menu item '%s'" $target $name }}
  20. {{ end }}
  21. {{ if eq $target "header" }}
  22. <span>
  23. <a
  24. href="{{ if .external -}}
  25. {{ .ref }}
  26. {{- else -}}
  27. {{ relref $current .ref }}
  28. {{- end }}"
  29. class="gdoc-header__link"
  30. >
  31. <svg class="gdoc-icon {{ .icon }}">
  32. <title>{{ $name }}</title>
  33. <use xlink:href="#{{ .icon }}"></use>
  34. </svg>
  35. </a>
  36. </span>
  37. {{ end }}
  38. {{ end }}
  39. {{ end }}
  40. {{ end }}