mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 09:43:06 +00:00
search: disable search in hidden branches #76
1-1-1-1 was previously displayed in the search results
This commit is contained in:
parent
97336b2339
commit
06486bdc3c
3 changed files with 56 additions and 54 deletions
|
@ -1,6 +1,6 @@
|
||||||
{{- $pages := slice }}
|
{{- $pages := slice }}
|
||||||
{{- range .Site.Pages }}
|
{{- range .Site.Pages }}
|
||||||
{{- if and (ne .Site.Params.disableSearchHiddenPages true) (or (ne .Params.hidden true) (ne .Title "")) }}
|
{{- if or (ne (.Scratch.Get "relearnIsHiddenTree") true) (ne .Site.Params.disableSearchHiddenPages true) }}
|
||||||
{{- $pages = $pages | append (dict "uri" .RelPermalink "title" .Title "tags" .Params.tags "description" .Description "content" (.Plain | htmlUnescape)) }}
|
{{- $pages = $pages | append (dict "uri" .RelPermalink "title" .Title "tags" .Params.tags "description" .Description "content" (.Plain | htmlUnescape)) }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -7,63 +7,12 @@
|
||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<!-- Next prev page -->
|
<!-- Next prev page -->
|
||||||
{{ $currentNode := . }}
|
|
||||||
|
|
||||||
{{ $currentNode.Scratch.Set "selfFound" nil }}
|
|
||||||
{{ $currentNode.Scratch.Set "prevPage" nil }}
|
|
||||||
{{ $currentNode.Scratch.Set "nextPage" nil }}
|
|
||||||
{{ template "menu-nextprev" dict "menu" .Site.Home "currentnode" $currentNode "hidden" false }}
|
|
||||||
|
|
||||||
{{ define "menu-nextprev" }}
|
|
||||||
{{ $currentNode := .currentnode }}
|
|
||||||
{{ $isSelf := eq $currentNode.RelPermalink .menu.RelPermalink }}
|
|
||||||
{{ $isDescendant := and (not $isSelf) (.menu.IsDescendant $currentNode) }}
|
|
||||||
{{ $isAncestor := and (not $isSelf) (.menu.IsAncestor $currentNode) }}
|
|
||||||
{{ $isOther := and (not $isDescendant) (not $isSelf) (not $isAncestor) }}
|
|
||||||
|
|
||||||
{{ if $isSelf }}
|
|
||||||
{{ $currentNode.Scratch.Set "selfFound" true }}
|
|
||||||
{{end}}
|
|
||||||
{{ $isSelfFound := eq ($currentNode.Scratch.Get "selfFound") true }}
|
|
||||||
{{ $isPreSelf := and (not $isSelfFound) (not $isSelf) }}
|
|
||||||
{{ $isPostSelf := and ($isSelfFound) (not $isSelf) }}
|
|
||||||
|
|
||||||
{{ $page_hidden := or (.menu.Params.hidden) (eq .menu.Title "") }}
|
|
||||||
{{ $hidden := or (and $page_hidden (not $isAncestor) (not $isSelf) ) (and .hidden (or $isPreSelf $isPostSelf $isDescendant) ) }}
|
|
||||||
|
|
||||||
{{ if not $hidden }}
|
|
||||||
{{if and $isPreSelf (or $isOther $isAncestor ) }}
|
|
||||||
{{ $currentNode.Scratch.Set "prevPage" .menu }}
|
|
||||||
{{else if and $isPostSelf (or $isOther $isDescendant) (eq ($currentNode.Scratch.Get "nextPage") nil) }}
|
|
||||||
{{ $currentNode.Scratch.Set "nextPage" .menu }}
|
|
||||||
{{end}}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ $currentNode.Scratch.Set "pages" .menu.Pages }}
|
|
||||||
{{ if .menu.IsHome}}
|
|
||||||
{{ $currentNode.Scratch.Set "pages" .menu.Sections }}
|
|
||||||
{{ else if .menu.Sections}}
|
|
||||||
{{ $currentNode.Scratch.Set "pages" (.menu.Pages | union .menu.Sections) }}
|
|
||||||
{{end}}
|
|
||||||
{{ $pages := ($currentNode.Scratch.Get "pages") }}
|
|
||||||
|
|
||||||
{{if eq .Site.Params.ordersectionsby "title"}}
|
|
||||||
{{ range $pages.ByTitle }}
|
|
||||||
{{ template "menu-nextprev" dict "menu" . "currentnode" $currentNode "hidden" $hidden }}
|
|
||||||
{{end}}
|
|
||||||
{{else}}
|
|
||||||
{{ range $pages.ByWeight }}
|
|
||||||
{{ template "menu-nextprev" dict "menu" . "currentnode" $currentNode "hidden" $hidden }}
|
|
||||||
{{end}}
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{$showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev))}}
|
{{$showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev))}}
|
||||||
{{if $showPrevNext}}
|
{{if $showPrevNext}}
|
||||||
{{with ($.Scratch.Get "prevPage")}}
|
{{with ($.Scratch.Get "relearnPrevPage")}}
|
||||||
<a class="nav nav-prev" href="{{.RelPermalink}}" title="{{.Title}}"><i class="fa fa-chevron-left"></i></a>
|
<a class="nav nav-prev" href="{{.RelPermalink}}" title="{{.Title}}"><i class="fa fa-chevron-left"></i></a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{with ($.Scratch.Get "nextPage")}}
|
{{with ($.Scratch.Get "relearnNextPage")}}
|
||||||
<a class="nav nav-next" href="{{.RelPermalink}}" title="{{.Title}}"><i class="fa fa-chevron-right"></i></a>
|
<a class="nav nav-next" href="{{.RelPermalink}}" title="{{.Title}}"><i class="fa fa-chevron-right"></i></a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -38,6 +38,59 @@
|
||||||
</style>
|
</style>
|
||||||
{{ partial "custom-header.html" . }}
|
{{ partial "custom-header.html" . }}
|
||||||
</head>
|
</head>
|
||||||
|
{{- $currentNode := . }}
|
||||||
|
{{- $currentNode.Scratch.Set "relearnIsSelfFound" nil }}
|
||||||
|
{{- $currentNode.Scratch.Set "relearnPrevPage" nil }}
|
||||||
|
{{- $currentNode.Scratch.Set "relearnNextPage" nil }}
|
||||||
|
{{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hidden" false }}
|
||||||
|
|
||||||
|
{{- define "relearn-structure" }}
|
||||||
|
{{- $currentNode := .currentnode }}
|
||||||
|
{{- $isSelf := eq $currentNode.RelPermalink .node.RelPermalink }}
|
||||||
|
{{- $isDescendant := and (not $isSelf) (.node.IsDescendant $currentNode) }}
|
||||||
|
{{- $isAncestor := and (not $isSelf) (.node.IsAncestor $currentNode) }}
|
||||||
|
{{- $isOther := and (not $isDescendant) (not $isSelf) (not $isAncestor) }}
|
||||||
|
|
||||||
|
{{- if $isSelf }}
|
||||||
|
{{- $currentNode.Scratch.Set "relearnIsSelfFound" true }}
|
||||||
|
{{- end}}
|
||||||
|
{{- $isSelfFound := eq ($currentNode.Scratch.Get "relearnIsSelfFound") true }}
|
||||||
|
{{- $isPreSelf := and (not $isSelfFound) (not $isSelf) }}
|
||||||
|
{{- $isPostSelf := and ($isSelfFound) (not $isSelf) }}
|
||||||
|
|
||||||
|
{{- $hidden_node := or (.node.Params.hidden) (eq .node.Title "") }}
|
||||||
|
{{- $hidden_tree:= 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}}
|
||||||
|
|
||||||
|
{{- if not $hidden_from_current }}
|
||||||
|
{{- if and $isPreSelf (or $isOther $isAncestor ) }}
|
||||||
|
{{- $currentNode.Scratch.Set "relearnPrevPage" .node }}
|
||||||
|
{{- else if and $isPostSelf (or $isOther $isDescendant) (eq ($currentNode.Scratch.Get "relearnNextPage") nil) }}
|
||||||
|
{{- $currentNode.Scratch.Set "relearnNextPage" .node }}
|
||||||
|
{{- end}}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- $currentNode.Scratch.Set "relearnSubPages" .node.Pages }}
|
||||||
|
{{- if .node.IsHome}}
|
||||||
|
{{- $currentNode.Scratch.Set "relearnSubPages" .node.Sections }}
|
||||||
|
{{- else if .node.Sections}}
|
||||||
|
{{- $currentNode.Scratch.Set "relearnSubPages" (.node.Pages | union .node.Sections) }}
|
||||||
|
{{- end}}
|
||||||
|
{{- $pages := ($currentNode.Scratch.Get "relearnSubPages") }}
|
||||||
|
|
||||||
|
{{- if eq .Site.Params.ordersectionsby "title"}}
|
||||||
|
{{- range $pages.ByTitle }}
|
||||||
|
{{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hidden" $hidden_from_current }}
|
||||||
|
{{- end}}
|
||||||
|
{{- else}}
|
||||||
|
{{- range $pages.ByWeight }}
|
||||||
|
{{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hidden" $hidden_from_current }}
|
||||||
|
{{- end}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
<body class="" data-url="{{ .RelPermalink }}">
|
<body class="" data-url="{{ .RelPermalink }}">
|
||||||
{{ partial "menu.html" . }}
|
{{ partial "menu.html" . }}
|
||||||
<section id="body">
|
<section id="body">
|
||||||
|
|
Loading…
Reference in a new issue