{{ $bookSection := default "docs" .Site.Params.BookSection }} {{ if eq $bookSection "*" }} {{ $bookSection = "/" }}{{/* Backward compatibility */}} {{ end }} {{ with .Site.GetPage $bookSection }} {{ template "book-section-children" (dict "Section" . "CurrentPage" $) }} {{ end }} {{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}} {{ $self := eq .CurrentPage .Section }} {{ $ancestor := .Section.IsAncestor .CurrentPage }} {{ $collapsed := .Section.Params.bookCollapseSection }} {{ if or $self $ancestor (not $collapsed) }}