From 3d0554124ad27b092ea57dab1fbb79820fb314a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Thu, 23 Sep 2021 22:27:58 +0200 Subject: [PATCH] menu: add default setting for menu expansion #97 --- exampleSite/content/basics/configuration/_index.en.md | 4 ++++ layouts/partials/menu.html | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/exampleSite/content/basics/configuration/_index.en.md b/exampleSite/content/basics/configuration/_index.en.md index 2365334102..d1c7e29eba 100644 --- a/exampleSite/content/basics/configuration/_index.en.md +++ b/exampleSite/content/basics/configuration/_index.en.md @@ -11,6 +11,10 @@ Note that some of these parameters are explained in details in other sections of ```toml [params] + # This controls whether submenus will be expanded (true), or collapsed (false) in the + # menu; if no setting is given, the first menu level is set to false, all others to true; + # this can be overridden in the pages frontmatter + alwaysopen = true # Prefix URL to edit current page. Will display an "Edit this page" button on top right hand corner of every page. # Useful to give opportunity to people to create merge request for your doc. # See the config.toml file from this documentation site to have an example. diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index 7075bb1ced..63fe665792 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -21,13 +21,14 @@ {{- end }}
@@ -113,13 +114,14 @@ {{- $currentNode.Scratch.Set "pages" (.Pages | union .Sections) }} {{- end }} {{- $pages := ($currentNode.Scratch.Get "pages") }} + {{- $defaultAlwaysopen := .Site.Params.alwaysopen | default true }} {{- if eq .Site.Params.ordersectionsby "title" }} {{- range $pages.ByTitle }} - {{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" true}} + {{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }} {{- end }} {{- else }} {{- range $pages.ByWeight }} - {{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" true}} + {{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }} {{- end }} {{- end }} {{- else }}