hugo-book-theme/layouts/partials/docs/menu-filetree.html

44 lines
1.6 KiB
HTML
Raw Normal View History

{{ $bookSection := default "docs" .Site.Params.BookSection }}
{{ if eq $bookSection "*" }}
{{ $bookSection = "/" }}{{/* Backward compatibility */}}
{{ end }}
2018-09-05 16:22:04 +02:00
{{ 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 := strings.HasPrefix .CurrentPage.RelPermalink .Section.RelPermalink }}
{{ $collapsed := .Section.Params.bookCollapseSection }}
{{ if or $self $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 }}
2018-09-18 01:35:54 +02:00
</ul>
{{ end }}
2018-09-18 01:35:54 +02:00
{{ 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 .Page }}active{{ end }}">
{{- partial "docs/title" .Page -}}
</a>
{{ else }}
<span>{{- partial "docs/title" .Page -}}</span>
{{ end }}
{{ end }}