#197, Use RelPermalink to identify nested pages in collapsed menu

This commit is contained in:
Alex Shpak 2020-04-14 22:56:31 +02:00
parent 9719692512
commit 94c8230e1e

View file

@ -8,10 +8,11 @@
{{ end }} {{ end }}
{{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}} {{ define "book-section-children" }}{{/* (dict "Section" .Section "CurrentPage" .CurrentPage) */}}
{{ $ancestor := .Section.IsAncestor .CurrentPage }} {{ $self := eq .CurrentPage .Section }}
{{ $ancestor := strings.HasPrefix .CurrentPage.RelPermalink .Section.RelPermalink }}
{{ $collapsed := .Section.Params.bookCollapseSection }} {{ $collapsed := .Section.Params.bookCollapseSection }}
{{ if or $ancestor (not $collapsed) }} {{ if or $self $ancestor (not $collapsed) }}
<ul> <ul>
{{ range (where .Section.Pages "Params.bookhidden" "ne" true) }} {{ range (where .Section.Pages "Params.bookhidden" "ne" true) }}
{{ if .IsSection }} {{ if .IsSection }}
@ -33,7 +34,7 @@
{{ if .Page.Content }} {{ if .Page.Content }}
<a href="{{ .Page.RelPermalink }}" class=" <a href="{{ .Page.RelPermalink }}" class="
{{- if and .Page.Params.bookCollapseSection .Page.IsSection }}collapsed {{ end }} {{- if and .Page.Params.bookCollapseSection .Page.IsSection }}collapsed {{ end }}
{{- if eq .CurrentPage.RelPermalink .Page.RelPermalink }}active{{ end }}"> {{- if eq .CurrentPage .Page }}active{{ end }}">
{{- partial "docs/title" .Page -}} {{- partial "docs/title" .Page -}}
</a> </a>
{{ else }} {{ else }}