#51, Add experimental bookCollapseSection page param to hide nested sections
This commit is contained in:
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user