hugo-theme-hilfe/layouts/partials/menu-bundle.html

82 lines
2.7 KiB
HTML
Raw Normal View History

2020-01-12 15:33:02 +01:00
{{ $current := .current }}
{{ template "menu-file" dict "sect" .source "current" $current "site" $current.Site }}
<!-- template -->
2020-01-12 15:33:02 +01:00
{{ define "menu-file" }}
{{ $current := .current }}
{{ $site := .site }}
2020-01-12 15:33:02 +01:00
<ul class="gdoc-nav__list">
{{ range sort (default (seq 0) .sect) "weight" }}
{{ $name := .name }}
{{ if reflect.IsMap .name }}
{{ $name = (index .name $site.Language.Lang) }}
{{ end }}
2020-01-12 15:33:02 +01:00
<li>
2020-01-12 15:33:02 +01:00
{{ $ref := default false .ref }}
{{ if $ref }}
{{ $this := $site.GetPage .ref }}
{{ $icon := default false .icon }}
{{ $numberOfPages := (add (len $this.Pages) (len $this.Sections)) }}
{{ $isCurrent := eq $current $this }}
{{ $isAncestor := $this.IsAncestor $current }}
{{ $id := substr (sha1 $this.Permalink) 0 8 }}
{{ $doCollapse := and (isset . "sub") (or $this.Params.GeekdocCollapseSection (default false .Site.Params.GeekdocCollapseAllSections)) }}
2020-01-12 15:33:02 +01:00
<input
type="checkbox"
{{ if $doCollapse }}
class="gdoc-nav__toggle" id="{{ printf "navtree-%s" $id }}"
{{ if or $isCurrent $isAncestor }}checked{{ end }}
{{ else }}
class="hidden"
{{ end }}
/>
<label
{{ if $doCollapse }}
for="{{ printf "navtree-%s" $id }}" class="flex justify-between align-center"
{{ end }}
>
2020-01-12 15:33:02 +01:00
<span class="flex">
{{ if $icon }}
<svg class="gdoc-icon {{ .icon }}"><use xlink:href="#{{ .icon }}"></use></svg>
{{ end }}
<a
href="{{ if .external }}
{{ .ref }}
{{ else }}
{{ relref $current .ref }}
{{ end }}"
class="gdoc-nav__entry{{- if not .external }}
{{- if $isCurrent }}{{ printf " is-active" }}{{ end }}
{{- end }}"
>
{{ $name }}
</a>
2020-01-12 15:33:02 +01:00
</span>
{{ if $doCollapse }}
<svg class="gdoc-icon toggle gdoc_keyboard_arrow_left">
<use xlink:href="#gdoc_keyboard_arrow_left"></use>
</svg>
<svg class="gdoc-icon toggle gdoc_keyboard_arrow_down hidden">
<use xlink:href="#gdoc_keyboard_arrow_down"></use>
</svg>
{{ end }}
</label>
2020-01-12 15:33:02 +01:00
{{ else }}
<span class="flex">{{ $name }}</span>
2020-01-12 15:33:02 +01:00
{{ end }}
{{ with .sub }}
{{ template "menu-file" dict "sect" . "current" $current "site" $site }}
2020-01-12 15:33:02 +01:00
{{ end }}
</li>
{{ end }}
</ul>
2020-01-12 15:33:02 +01:00
{{ end }}