From e2188136e102ca7790f0b9e5efec65b49face6f1 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Wed, 9 Oct 2019 01:00:26 +0200 Subject: #51, Add experimental bookCollapseSection page param to hide nested sections --- layouts/partials/docs/menu-filetree.html | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'layouts/partials/docs/menu-filetree.html') 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 }} {{ end }} {{ define "book-section" }} {{ with .Section }} -
  • +
  • {{ 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 }} + {{ end }} {{ end }} + {{ end }} {{ define "book-page-link" }} {{ with .Page }} - + {{ partial "docs/title" . }} {{ end }} -- cgit v1.2.3