Merge pull request #5 from y1450/menu-ux

menu ux : handling active page
This commit is contained in:
DhammaCharts 2022-07-13 12:57:03 +01:00 committed by GitHub
commit bdce6332fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View File

@ -129,6 +129,17 @@
true
);
// open all parents items of selected page
document.querySelectorAll('a.active').forEach(function(child){
while(!child.classList.contains("tree")){
if (child.tagName=="DETAILS"){
child.open=true
}
child=child.parentElement;
}
});
{{end}}
{{if $.Site.Data.config.enableLinkPreview}}

View File

@ -17,7 +17,7 @@
{{ range (where .Section.Pages "Params.bookhidden" "ne" true) }}
{{ if .IsSection }}
<details open>
<details>
<summary>
{{ template "book-page-link" (dict "Page" . "CurrentPage" $.CurrentPage) }}
</summary>
@ -35,16 +35,7 @@
{{ define "book-page-link" }}{{/* (dict "Page" .Page "CurrentPage" .CurrentPage) */}}
{{ $current := eq .CurrentPage .Page }}
{{ $ancestor := .Page.IsAncestor .CurrentPage }}
{{ if .Page.Params.bookCollapseSection }}
<input type="checkbox" id="section-{{ md5 .Page }}" class="toggle" {{ if or $current $ancestor }}checked{{ end }} />
<label for="section-{{ md5 .Page }}" class="flex justify-between">
<a {{ if .Page.Content }}href="{{ .Page.Permalink }}"{{ else }}role="button"{{ end }} class="{{ if $current }}active{{ end }}">
{{- partial "docs/title" .Page -}}
</a>
</label>
{{ else if .Page.Content }}
{{if .Page.Content }}
<a href="{{ .Page.Permalink }}" class="{{ if $current }}active{{ end }}">
{{- partial "title" .Page -}}