2019-04-22 17:17:39 +00:00
|
|
|
{{ $bookSection := default "docs" .Site.Params.BookSection }}
|
|
|
|
{{ if eq $bookSection "*" }}
|
2020-04-11 12:35:29 +00:00
|
|
|
{{ $bookSection = "/" }}{{/* Backward compatibility */}}
|
2019-04-22 17:17:39 +00:00
|
|
|
{{ end }}
|
2018-09-05 14:22:04 +00:00
|
|
|
|
2020-04-11 12:35:29 +00:00
|
|
|
{{ with .Site.GetPage $bookSection }}
|
|
|
|
{{ template "book-section-children" (dict "Section" . "CurrentPage" $) }}
|
2019-04-22 17:17:39 +00:00
|
|
|
{{ end }}
|
|
|
|
|
2020-04-11 12:35:29 +00:00
|
|
|
{{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}}
|
2019-04-22 17:17:39 +00:00
|
|
|
<ul>
|
2020-04-11 12:35:29 +00:00
|
|
|
{{ range (where .Section.Pages "Params.bookhidden" "ne" true) }}
|
2020-03-30 16:00:15 +00:00
|
|
|
{{ if .IsSection }}
|
2020-04-11 12:35:29 +00:00
|
|
|
<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>
|
2022-04-26 11:14:22 +00:00
|
|
|
{{ else if and .IsPage .Content }}
|
2019-08-29 04:53:19 +00:00
|
|
|
<li>
|
2020-04-11 12:35:29 +00:00
|
|
|
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
|
2019-08-29 04:53:19 +00:00
|
|
|
</li>
|
|
|
|
{{ end }}
|
2018-09-17 16:29:36 +00:00
|
|
|
{{ end }}
|
2018-09-17 23:35:54 +00:00
|
|
|
</ul>
|
|
|
|
{{ end }}
|
2019-10-08 23:00:26 +00:00
|
|
|
|
2020-04-11 12:35:29 +00:00
|
|
|
{{ define "book-page-link" }}{{/* (dict "Page" .Page "CurrentPage" .CurrentPage) */}}
|
2020-09-14 20:45:31 +00:00
|
|
|
{{ $current := eq .CurrentPage .Page }}
|
|
|
|
{{ $ancestor := .Page.IsAncestor .CurrentPage }}
|
|
|
|
|
2022-04-26 11:14:22 +00:00
|
|
|
{{ if .Page.Params.BookCollapseSection }}
|
2020-09-14 20:45:31 +00:00
|
|
|
<input type="checkbox" id="section-{{ md5 .Page }}" class="toggle" {{ if or $current $ancestor }}checked{{ end }} />
|
|
|
|
<label for="section-{{ md5 .Page }}" class="flex justify-between">
|
2022-02-18 16:35:02 +00:00
|
|
|
<a {{ if .Page.Content }}href="{{ .Page.RelPermalink }}"{{ else }}role="button"{{ end }} class="{{ if $current }}active{{ end }}">
|
2020-09-14 20:45:31 +00:00
|
|
|
{{- partial "docs/title" .Page -}}
|
|
|
|
</a>
|
|
|
|
</label>
|
2022-04-26 11:14:22 +00:00
|
|
|
{{ else if .Page.Params.BookHref }}
|
|
|
|
<a href="{{ .Page.Params.BookHref }}" class="{{ if $current }}active{{ end }}" target="_blank" rel="noopener">
|
2020-04-11 12:35:29 +00:00
|
|
|
{{- partial "docs/title" .Page -}}
|
|
|
|
</a>
|
2022-04-26 11:14:22 +00:00
|
|
|
{{ else if .Page.Content }}
|
|
|
|
<a href="{{ .Page.RelPermalink }}" class="{{ if $current }}active{{ end }}">
|
2022-04-26 11:10:39 +00:00
|
|
|
{{- partial "docs/title" .Page -}}
|
|
|
|
</a>
|
2020-02-29 20:15:52 +00:00
|
|
|
{{ else }}
|
2020-04-11 12:35:29 +00:00
|
|
|
<span>{{- partial "docs/title" .Page -}}</span>
|
2020-02-29 20:15:52 +00:00
|
|
|
{{ end }}
|
2019-04-22 17:17:39 +00:00
|
|
|
{{ end }}
|