mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2024-11-25 04:43:04 +00:00
43 lines
1.6 KiB
HTML
43 lines
1.6 KiB
HTML
{{ $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) */}}
|
|
{{ $ancestor := .Section.IsAncestor .CurrentPage }}
|
|
{{ $collapsed := .Section.Params.bookCollapseSection }}
|
|
|
|
{{ if or $ancestor (not $collapsed) }}
|
|
<ul>
|
|
{{ range (where .Section.Pages "Params.bookhidden" "ne" true) }}
|
|
{{ if .IsSection }}
|
|
<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) }}
|
|
</li>
|
|
{{ end }}
|
|
{{ end }}
|
|
</ul>
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ 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" .Page -}}</span>
|
|
{{ end }}
|
|
{{ end }}
|