feat: collapse every section (#162)

This allows setting `.Site.Params.GeekdocCollapseAllSections` which then
behaves as if you would have set `.Page.Params.geekdocCollapseSection`
in all sections.

It is a hard positive switch, so you can not override it per section
once enabled.

Co-authored-by: Robert Kaussow <xoxys@rknet.org>

Co-authored-by: Robert Kaussow <xoxys@rknet.org>
uci-hugo-doc
Oluf Lorenzen 2021-07-10 13:17:16 +02:00 committed by GitHub
parent 4af402a3d3
commit 56a0d44a50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -134,6 +134,10 @@ params:
# See also https://geekdocs.de/usage/menus/#bundle-menu # See also https://geekdocs.de/usage/menus/#bundle-menu
geekdocMenuBundle: true geekdocMenuBundle: true
# (Optional, default false) Collapse all menu entries, can not be overwritten
# per page if enabled. Can be enabled per page via `geekdocCollapseSection`
geekdocCollapseAllSections: true
# (Optional, default true) Show page navigation links at the bottom of each # (Optional, default true) Show page navigation links at the bottom of each
# docs page (bundle menu only). # docs page (bundle menu only).
geekdocNextPrev: false geekdocNextPrev: false

View File

@ -22,9 +22,9 @@
{{ $isCurrent := eq $current $this }} {{ $isCurrent := eq $current $this }}
{{ $isAncestor := $this.IsAncestor $current }} {{ $isAncestor := $this.IsAncestor $current }}
{{ $id := substr (sha1 $this.Permalink) 0 8 }} {{ $id := substr (sha1 $this.Permalink) 0 8 }}
{{ $hasCollapse := and $this.Params.GeekdocCollapseSection (isset . "sub") }} {{ $doCollapse := and (isset . "sub") (or $this.Params.GeekdocCollapseSection (default false .Site.Params.GeekdocCollapseAllSections)) }}
{{ if $hasCollapse }} {{ if $doCollapse }}
<input type="checkbox" id="{{ printf "navtree-%s" $id }}" class="gdoc-nav__toggle" {{ if or $isCurrent $isAncestor }}checked{{ end }}> <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"> <label for="{{ printf "navtree-%s" $id }}" class="flex justify-between">
{{ end }} {{ end }}
@ -35,7 +35,7 @@
{{ .name }} {{ .name }}
</a> </a>
</span> </span>
{{ if $hasCollapse }} {{ if $doCollapse }}
<svg class="icon gdoc_keyborad_arrow_left"><use xlink:href="#gdoc_keyborad_arrow_left"></use></svg> <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> <svg class="icon gdoc_keyborad_arrow_down hidden"><use xlink:href="#gdoc_keyborad_arrow_down"></use></svg>
</label> </label>

View File

@ -15,10 +15,10 @@
{{ $isCurrent := eq $current . }} {{ $isCurrent := eq $current . }}
{{ $isAncestor := .IsAncestor $current }} {{ $isAncestor := .IsAncestor $current }}
{{ $id := substr (sha1 .Permalink) 0 8 }} {{ $id := substr (sha1 .Permalink) 0 8 }}
{{ $hasCollapse := and $isParent .Params.GeekdocCollapseSection }} {{ $doCollapse := and $isParent (or .Params.GeekdocCollapseSection (default false .Site.Params.GeekdocCollapseAllSections)) }}
<li> <li>
{{ if $hasCollapse }} {{ if $doCollapse }}
<input type="checkbox" id="{{ printf "navtree-%s" $id }}" class="gdoc-nav__toggle" {{ if or $isCurrent $isAncestor }}checked{{ end }}> <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"> <label for="{{ printf "navtree-%s" $id }}" class="flex justify-between">
{{ end }} {{ end }}
@ -31,7 +31,7 @@
{{ else }} {{ else }}
<span class="flex">{{ partial "title" . }}</span> <span class="flex">{{ partial "title" . }}</span>
{{ end }} {{ end }}
{{ if $hasCollapse }} {{ if $doCollapse }}
<svg class="icon gdoc_keyborad_arrow_left"><use xlink:href="#gdoc_keyborad_arrow_left"></use></svg> <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> <svg class="icon gdoc_keyborad_arrow_down hidden"><use xlink:href="#gdoc_keyborad_arrow_down"></use></svg>
</label> </label>