diff options
author | Alex Shpak <alex-shpak@users.noreply.github.com> | 2019-10-09 01:00:26 +0200 |
---|---|---|
committer | Alex Shpak <alex-shpak@users.noreply.github.com> | 2019-10-09 01:00:40 +0200 |
commit | e2188136e102ca7790f0b9e5efec65b49face6f1 (patch) | |
tree | fcbd347112142c72263d4c00120666dae4364e56 /layouts | |
parent | 071e069d929df9b8bf50f6ab31d69e10bcf5c892 (diff) |
#51, Add experimental bookCollapseSection page param to hide nested sections
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/docs/menu-filetree.html | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/layouts/partials/docs/menu-filetree.html b/layouts/partials/docs/menu-filetree.html index c8dd86b..c917828 100644 --- a/layouts/partials/docs/menu-filetree.html +++ b/layouts/partials/docs/menu-filetree.html @@ -11,19 +11,19 @@ {{/* If there is only one section to render then render its children, else render all sections */}} {{ if eq (len $sections) 1 }} {{ with index $sections 0 }} - {{ template "book-section-children" (dict "Section" . "CurrentPage" $.Permalink) }} + {{ template "book-section-children" (dict "Section" . "CurrentPage" $) }} {{ end }} {{ else }} <ul> {{ range where $sections "Params.bookhidden" "!=" true }} - {{ template "book-section" (dict "Section" . "CurrentPage" $.Permalink) }} + {{ template "book-section" (dict "Section" . "CurrentPage" $) }} {{ end }} </ul> {{ end }} {{ define "book-section" }} {{ with .Section }} - <li {{ if .Params.BookFlatSection}} class="book-section-flat" {{ end }}> + <li {{ if .Params.BookFlatSection }} class="book-section-flat" {{ end }}> {{ if .Content }} {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }} {{ else }} @@ -36,7 +36,11 @@ {{ end }} {{ define "book-section-children" }} -{{ with .Section }} +{{ $ancestor := .Section.IsAncestor .CurrentPage }} +{{ $collapsed := .Section.Params.bookCollapseSection }} + +{{ if or $ancestor (not $collapsed) }} + {{ with .Section }} <ul> {{ range where .Pages "Params.bookhidden" "!=" "true" }} {{ if eq .Kind "section" }} @@ -48,12 +52,14 @@ {{ end }} {{ end }} </ul> + {{ end }} {{ end }} + {{ end }} {{ define "book-page-link" }} {{ with .Page }} - <a href="{{ .RelPermalink }}" {{ if eq $.CurrentPage .Permalink }} class="active"{{ end }}> + <a href="{{ .RelPermalink }}" {{ if eq $.CurrentPage . }} class="active"{{ end }}> {{ partial "docs/title" . }} </a> {{ end }} |