#157, Refactor side menu, simpler and renders all pages at root
This commit is contained in:
@@ -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 }}
|
||||
|
||||
{{ with .Site.GetPage $bookSection }}
|
||||
{{ template "book-section-children" (dict "Section" . "CurrentPage" $) }}
|
||||
{{ 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 }}
|
||||
{{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}}
|
||||
{{ $ancestor := .Section.IsAncestor .CurrentPage }}
|
||||
{{ $collapsed := .Section.Params.bookCollapseSection }}
|
||||
|
||||
{{ if or $ancestor (not $collapsed) }}
|
||||
<ul>
|
||||
{{ range where $sections "Params.bookHidden" "!=" true }}
|
||||
{{ template "book-section" (dict "Section" . "CurrentPage" $) }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
|
||||
{{ define "book-section" }}
|
||||
{{ with .Section }}
|
||||
<li {{- if .Params.BookFlatSection }} class="book-section-flat" {{ end }}>
|
||||
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
||||
{{ template "book-section-children" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ define "book-section-children" }}
|
||||
{{ $ancestor := .Section.IsAncestor .CurrentPage }}
|
||||
{{ $collapsed := .Section.Params.bookCollapseSection }}
|
||||
|
||||
{{ if or $ancestor (not $collapsed) }}
|
||||
{{ with .Section }}
|
||||
<ul>
|
||||
{{ range where .Pages "Params.bookhidden" "!=" "true" }}
|
||||
{{ range (where .Section.Pages "Params.bookhidden" "ne" true) }}
|
||||
{{ if .IsSection }}
|
||||
{{ template "book-section" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
||||
<li {{- if .Params.BookFlatSection }} class="book-section-flat" {{ end -}}>
|
||||
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
||||
{{ template "book-section-children" (dict "Section" . "CurrentPage" $.CurrentPage) }}
|
||||
</li>
|
||||
{{ else if and .IsPage .Content }}
|
||||
<li>
|
||||
{{- template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) -}}
|
||||
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@@ -50,18 +29,14 @@
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
|
||||
{{ define "book-page-link" }}
|
||||
{{ with .Page }}
|
||||
{{ if .Content }}
|
||||
<a href="{{ .RelPermalink }}" class="
|
||||
{{- if and .Params.bookCollapseSection .IsSection }}collapsed {{ end }}
|
||||
{{- if eq $.CurrentPage.RelPermalink .RelPermalink }}active{{ end }}">
|
||||
{{- partial "docs/title" . -}}
|
||||
</a>
|
||||
{{ define "book-page-link" }}{{/* (dict "Page" .Page "CurrentPage" .CurrentPage) */}}
|
||||
{{ if .Page.Content }}
|
||||
<a href="{{ .Page.RelPermalink }}" class="
|
||||
{{- if and .Page.Params.bookCollapseSection .Page.IsSection }}collapsed {{ end }}
|
||||
{{- if eq .CurrentPage.RelPermalink .Page.RelPermalink }}active{{ end }}">
|
||||
{{- partial "docs/title" .Page -}}
|
||||
</a>
|
||||
{{ else }}
|
||||
<span>{{- partial "docs/title" . -}}</span>
|
||||
<span>{{- partial "docs/title" .Page -}}</span>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{{ define "main" }}
|
||||
{{ $paginator := .Paginate (where .Pages "Params.hidden" "ne" true) }}
|
||||
{{ range sort .Paginator.Pages }}
|
||||
<article class="markdown book-post">
|
||||
<h2>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{{ define "main" }}
|
||||
{{ $paginator := .Paginate (where .Pages "Params.hidden" "ne" true) }}
|
||||
{{ range sort .Paginator.Pages }}
|
||||
<article class="markdown book-post">
|
||||
<h2>
|
||||
@@ -9,11 +8,12 @@
|
||||
<p>
|
||||
{{- .Summary -}}
|
||||
{{ if .Truncated }}
|
||||
<a href="{{ .RelPermalink }}">...</a>
|
||||
<a href="{{ .RelPermalink }}">...</a>
|
||||
{{ end }}
|
||||
</p>
|
||||
</article>
|
||||
{{ end }}
|
||||
|
||||
{{ template "_internal/pagination.html" . }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user