From 15339ab6a6f39729bd1be500e7fc32b89eb37b55 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Sat, 11 Apr 2020 14:35:29 +0200 Subject: #157, Refactor side menu, simpler and renders all pages at root --- layouts/partials/docs/menu-filetree.html | 67 ++++++++++---------------------- 1 file changed, 21 insertions(+), 46 deletions(-) (limited to 'layouts/partials/docs') diff --git a/layouts/partials/docs/menu-filetree.html b/layouts/partials/docs/menu-filetree.html index e3db53b..489a62f 100644 --- a/layouts/partials/docs/menu-filetree.html +++ b/layouts/partials/docs/menu-filetree.html @@ -1,48 +1,27 @@ {{ $bookSection := default "docs" .Site.Params.BookSection }} {{ if eq $bookSection "*" }} - {{ .Scratch.Set "BookSections" .Site.Sections }} -{{ else }} - {{ $bookSections := where .Site.Sections "Section" $bookSection }} - {{ .Scratch.Set "BookSections" $bookSections }} + {{ $bookSection = "/" }}{{/* Backward compatibility */}} {{ end }} - -{{ $sections := .Scratch.Get "BookSections" }} -{{/* 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" $) }} - {{ end }} -{{ else }} - -{{ end }} - -{{ define "book-section" }} -{{ with .Section }} -
  • - {{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }} - {{ template "book-section-children" (dict "Section" . "CurrentPage" $.CurrentPage) }} -
  • -{{ end }} +{{ with .Site.GetPage $bookSection }} + {{ template "book-section-children" (dict "Section" . "CurrentPage" $) }} {{ end }} -{{ define "book-section-children" }} -{{ $ancestor := .Section.IsAncestor .CurrentPage }} -{{ $collapsed := .Section.Params.bookCollapseSection }} +{{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}} + {{ $ancestor := .Section.IsAncestor .CurrentPage }} + {{ $collapsed := .Section.Params.bookCollapseSection }} -{{ if or $ancestor (not $collapsed) }} - {{ with .Section }} + {{ if or $ancestor (not $collapsed) }}