From 56a0d44a50c943c44be54d889d315237d5acf48f Mon Sep 17 00:00:00 2001 From: Oluf Lorenzen Date: Sat, 10 Jul 2021 13:17:16 +0200 Subject: [PATCH] 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 Co-authored-by: Robert Kaussow --- exampleSite/content/usage/configuration.md | 4 ++++ layouts/partials/menu-bundle.html | 6 +++--- layouts/partials/menu-filetree.html | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/exampleSite/content/usage/configuration.md b/exampleSite/content/usage/configuration.md index 3f18a89..5b91d8d 100644 --- a/exampleSite/content/usage/configuration.md +++ b/exampleSite/content/usage/configuration.md @@ -134,6 +134,10 @@ params: # See also https://geekdocs.de/usage/menus/#bundle-menu 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 # docs page (bundle menu only). geekdocNextPrev: false diff --git a/layouts/partials/menu-bundle.html b/layouts/partials/menu-bundle.html index 51c0807..64f23aa 100644 --- a/layouts/partials/menu-bundle.html +++ b/layouts/partials/menu-bundle.html @@ -22,9 +22,9 @@ {{ $isCurrent := eq $current $this }} {{ $isAncestor := $this.IsAncestor $current }} {{ $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 }} diff --git a/layouts/partials/menu-filetree.html b/layouts/partials/menu-filetree.html index d78df85..6024a06 100644 --- a/layouts/partials/menu-filetree.html +++ b/layouts/partials/menu-filetree.html @@ -15,10 +15,10 @@ {{ $isCurrent := eq $current . }} {{ $isAncestor := .IsAncestor $current }} {{ $id := substr (sha1 .Permalink) 0 8 }} - {{ $hasCollapse := and $isParent .Params.GeekdocCollapseSection }} + {{ $doCollapse := and $isParent (or .Params.GeekdocCollapseSection (default false .Site.Params.GeekdocCollapseAllSections)) }}
  • - {{ if $hasCollapse }} + {{ if $doCollapse }}