hugo-geekdoc/layouts/partials/menu-bundle.html

55 lines
2.3 KiB
HTML
Raw Permalink Normal View History

2020-01-12 14:33:02 +00:00
{{ $current := .current }}
{{ template "menu-file" dict "sect" .source "current" $current "site" $current.Site }}
<!-- template -->
2020-01-12 14:33:02 +00:00
{{ define "menu-file" }}
{{ $current := .current }}
{{ $site := .site }}
<ul class="gdoc-nav__list">
2020-02-05 15:46:29 +00:00
{{ range sort (default (seq 0) .sect) "weight" }}
2020-01-12 14:33:02 +00:00
{{ $current.Scratch.Set "current" $current }}
{{ $current.Scratch.Set "site" $site }}
<li>
{{ $ref := default false .ref }}
{{ if $ref}}
{{ $site := $current.Scratch.Get "site" }}
{{ $this := $site.GetPage .ref }}
{{ $current := $current.Scratch.Get "current" }}
{{ $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 }}
{{ $hasCollapse := and $this.Params.GeekdocCollapseSection (isset . "sub") }}
2020-01-12 14:33:02 +00:00
{{ if $hasCollapse }}
<input type="checkbox" id="{{ printf "navtree-%s" $id }}" class="gdoc-nav__toggle" {{ if or $isCurrent $isAncestor }}checked{{ end }}>
<label for="{{ printf "navtree-%s" $id }}" class="flex justify-between">
{{ end }}
2020-01-12 14:33:02 +00:00
<span class="flex">
{{ if $icon }}<svg class="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 }}is-active{{ end }}{{ end }}">
2020-01-12 14:33:02 +00:00
{{ .name }}
</a>
</span>
{{ if $hasCollapse }}
<svg class="icon gdoc_keyborad_arrow_left"><use xlink:href="#gdoc_keyborad_arrow_left"></use></svg>
<svg class="icon gdoc_keyborad_arrow_down hidden"><use xlink:href="#gdoc_keyborad_arrow_down"></use></svg>
</label>
{{ end }}
2020-01-12 14:33:02 +00:00
{{ else }}
<span class="flex">{{ .name }}</span>
2020-01-12 14:33:02 +00:00
{{ end }}
{{ with .sub }}
{{ template "menu-file" dict "sect" . "current" ($current.Scratch.Get "current") "site" ($current.Scratch.Get "site") }}
2020-01-12 14:33:02 +00:00
{{ end }}
</li>
{{ end }}
</ul>
{{ end }}