menu: add default setting for menu expansion #97

This commit is contained in:
Sören Weber 2021-09-23 22:27:58 +02:00
parent a96e6b93f8
commit 3d0554124a
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
2 changed files with 10 additions and 4 deletions

View file

@ -11,6 +11,10 @@ Note that some of these parameters are explained in details in other sections of
```toml ```toml
[params] [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. # 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. # 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. # See the config.toml file from this documentation site to have an example.

View file

@ -21,13 +21,14 @@
{{- end }} {{- end }}
<div class="highlightable"> <div class="highlightable">
<ul class="topics"> <ul class="topics">
{{- $defaultAlwaysopen := .Site.Params.alwaysopen | default false }}
{{- if eq .Site.Params.ordersectionsby "title" }} {{- if eq .Site.Params.ordersectionsby "title" }}
{{- range .Site.Home.Sections.ByTitle }} {{- range .Site.Home.Sections.ByTitle }}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" false }} {{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }}
{{- end }} {{- end }}
{{- else }} {{- else }}
{{- range .Site.Home.Sections.ByWeight }} {{- range .Site.Home.Sections.ByWeight }}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" false }} {{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }}
{{- end }} {{- end }}
{{- end }} {{- end }}
</ul> </ul>
@ -113,13 +114,14 @@
{{- $currentNode.Scratch.Set "pages" (.Pages | union .Sections) }} {{- $currentNode.Scratch.Set "pages" (.Pages | union .Sections) }}
{{- end }} {{- end }}
{{- $pages := ($currentNode.Scratch.Get "pages") }} {{- $pages := ($currentNode.Scratch.Get "pages") }}
{{- $defaultAlwaysopen := .Site.Params.alwaysopen | default true }}
{{- if eq .Site.Params.ordersectionsby "title" }} {{- if eq .Site.Params.ordersectionsby "title" }}
{{- range $pages.ByTitle }} {{- 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 }} {{- end }}
{{- else }} {{- else }}
{{- range $pages.ByWeight }} {{- 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 }}
{{- end }}</ul></li> {{- end }}</ul></li>
{{- else }} {{- else }}