menu: always hide hidden sub pages #77

This commit is contained in:
Sören Weber 2021-09-04 00:17:47 +02:00
parent a57b650388
commit c969f3b13f
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
4 changed files with 12 additions and 12 deletions

View file

@ -1,6 +1,6 @@
{{- $pages := slice }}
{{- range .Site.Pages }}
{{- if or (ne (.Scratch.Get "relearnIsHiddenTree") true) (ne .Site.Params.disableSearchHiddenPages true) }}
{{- if or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) }}
{{- $pages = $pages | append (dict "uri" .RelPermalink "title" .Title "tags" .Params.tags "description" .Description "content" (.Plain | htmlUnescape)) }}
{{- end }}
{{- end }}

View file

@ -59,16 +59,15 @@
{{- $isPostSelf := and ($isSelfFound) (not $isSelf) }}
{{- $hidden_node := or (.node.Params.hidden) (eq .node.Title "") }}
{{- $hidden_tree:= or $hidden_node .hidden }}
{{- $hidden_stem:= or $hidden_node .hidden }}
{{- $hidden_from_current := or (and $hidden_node (not $isAncestor) (not $isSelf) ) (and .hidden (or $isPreSelf $isPostSelf $isDescendant) ) }}
{{- .node.Scratch.Set "relearnIsHiddenNode" $hidden_node}}
{{- .node.Scratch.Set "relearnIsHiddenTree" $hidden_tree}}
{{- .node.Scratch.Set "relearnIsHiddenFromCurrent" $hidden_from_current}}
{{- .node.Scratch.Set "relearnIsHiddenStem" $hidden_stem}}
{{- if not $hidden_from_current }}
{{- if and $isPreSelf (or $isOther $isAncestor ) }}
{{- if $isPreSelf }}
{{- $currentNode.Scratch.Set "relearnPrevPage" .node }}
{{- else if and $isPostSelf (or $isOther $isDescendant) (eq ($currentNode.Scratch.Get "relearnNextPage") nil) }}
{{- else if and $isPostSelf (eq ($currentNode.Scratch.Get "relearnNextPage") nil) }}
{{- $currentNode.Scratch.Set "relearnNextPage" .node }}
{{- end}}
{{- end }}

View file

@ -105,11 +105,12 @@
{{ $alwaysopen := .alwaysopen }}
{{ with $currentNode.File }}{{ $currentFileUniqueID = .UniqueID }}{{ end }}
{{with .sect}}
{{ $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
{{if .IsSection }}
{{ $hidden := and (eq (.Scratch.Get "relearnIsHiddenStem") true) (not $.showhidden) (not (.IsAncestor $currentNode))}}
{{if $hidden }}
{{else if .IsSection }}
{{safeHTML .Params.head}}
{{ $currentAlwaysopen := .Params.alwaysopen | default $alwaysopen }}
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item{{if eq .File.UniqueID $currentFileUniqueID}} active{{end}}{{if .IsAncestor $currentNode }} parent{{end}}{{if $currentAlwaysopen}} alwaysopen{{end}}{{if $hidden}} hidden{{end}}">
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item{{if eq .File.UniqueID $currentFileUniqueID}} active{{end}}{{if .IsAncestor $currentNode }} parent{{end}}{{if $currentAlwaysopen}} alwaysopen{{end}}">
<a href="{{.RelPermalink}}">
{{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }}
{{ if $showvisitedlinks}}<i class="fas fa-check read-icon"></i>{{end}}

View file

@ -210,7 +210,7 @@ textarea:focus, input[type="email"]:focus, input[type="number"]:focus, input[typ
#sidebar ul.topics.searched ul {
display: block;
}
#sidebar ul.topics ul, #sidebar ul.topics li.hidden {
#sidebar ul.topics ul {
display: none;
}
#sidebar ul.topics > li > ul > li:last-child {
@ -219,8 +219,8 @@ textarea:focus, input[type="email"]:focus, input[type="number"]:focus, input[typ
#sidebar ul.topics ul ul {
padding-bottom: 0;
}
#sidebar ul.topics li.parent > ul, #sidebar ul.topics li.parent.hidden,
#sidebar ul.topics li.active > ul, #sidebar ul.topics li.active.hidden,
#sidebar ul.topics li.parent > ul,
#sidebar ul.topics li.active > ul,
#sidebar ul.topics li.alwaysopen > ul {
display: block;
}