mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
menu: show hidden pages if accessed directly #60
This commit is contained in:
parent
c81bf82ced
commit
d3f70bd846
5 changed files with 16 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
||||||
+++
|
+++
|
||||||
chapter = true
|
chapter = true
|
||||||
|
hidden = true
|
||||||
title = "This could be yours"
|
title = "This could be yours"
|
||||||
weight = 4
|
weight = 4
|
||||||
+++
|
+++
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
|
|
||||||
{{ define "menu-nextprev" }}
|
{{ define "menu-nextprev" }}
|
||||||
{{$currentNode := .currentnode }}
|
{{$currentNode := .currentnode }}
|
||||||
{{ if and (ne .menu.Params.hidden true) (ne .menu.Title "") }}
|
{{ $hidden := or (.menu.Params.hidden) (eq .menu.Title "") }}
|
||||||
|
{{ if not $hidden }}
|
||||||
{{if hasPrefix $currentNode.RelPermalink .menu.RelPermalink }}
|
{{if hasPrefix $currentNode.RelPermalink .menu.RelPermalink }}
|
||||||
{{ $currentNode.Scratch.Set "NextPageOK" "OK" }}
|
{{ $currentNode.Scratch.Set "NextPageOK" "OK" }}
|
||||||
{{ $currentNode.Scratch.Set "prevPage" ($currentNode.Scratch.Get "prevPageTmp") }}
|
{{ $currentNode.Scratch.Set "prevPage" ($currentNode.Scratch.Get "prevPageTmp") }}
|
||||||
|
|
|
@ -105,14 +105,11 @@
|
||||||
{{ $alwaysopen := .alwaysopen }}
|
{{ $alwaysopen := .alwaysopen }}
|
||||||
{{ with $currentNode.File }}{{ $currentFileUniqueID = .UniqueID }}{{ end }}
|
{{ with $currentNode.File }}{{ $currentFileUniqueID = .UniqueID }}{{ end }}
|
||||||
{{with .sect}}
|
{{with .sect}}
|
||||||
{{if and .IsSection (or (and (not .Params.hidden) (ne .Title "")) $.showhidden )}}
|
{{ $page_hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
|
||||||
|
{{if .IsSection }}
|
||||||
{{safeHTML .Params.head}}
|
{{safeHTML .Params.head}}
|
||||||
{{ $currentAlwaysopen := .Params.alwaysopen | default $alwaysopen }}
|
{{ $currentAlwaysopen := .Params.alwaysopen | default $alwaysopen }}
|
||||||
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item
|
<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 $page_hidden}} hidden{{end}}">
|
||||||
{{if eq .File.UniqueID $currentFileUniqueID}} active{{end}}
|
|
||||||
{{if .IsAncestor $currentNode }} parent{{end}}
|
|
||||||
{{if $currentAlwaysopen}} alwaysopen{{end}}
|
|
||||||
">
|
|
||||||
<a href="{{.RelPermalink}}">
|
<a href="{{.RelPermalink}}">
|
||||||
{{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }}
|
{{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }}
|
||||||
{{ if $showvisitedlinks}}<i class="fas fa-check read-icon"></i>{{end}}
|
{{ if $showvisitedlinks}}<i class="fas fa-check read-icon"></i>{{end}}
|
||||||
|
@ -126,25 +123,17 @@
|
||||||
|
|
||||||
{{if eq .Site.Params.ordersectionsby "title"}}
|
{{if eq .Site.Params.ordersectionsby "title"}}
|
||||||
{{ range $pages.ByTitle }}
|
{{ range $pages.ByTitle }}
|
||||||
{{ if and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
|
{{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" true}}
|
||||||
{{else}}
|
|
||||||
{{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" true}}
|
|
||||||
{{end}}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{ range $pages.ByWeight }}
|
{{ range $pages.ByWeight }}
|
||||||
{{ if and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
|
{{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" true}}
|
||||||
{{else}}
|
|
||||||
{{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" true}}
|
|
||||||
{{end}}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{end}}
|
{{end}}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{{else if and (not .Params.hidden) (ne .Title "") }}
|
{{else}}
|
||||||
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item
|
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item{{if eq .File.UniqueID $currentFileUniqueID}} active{{end}}">
|
||||||
{{if eq .File.UniqueID $currentFileUniqueID}} active{{end}}
|
|
||||||
">
|
|
||||||
<a href="{{ .RelPermalink}}">
|
<a href="{{ .RelPermalink}}">
|
||||||
{{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }}
|
{{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }}
|
||||||
{{ if $showvisitedlinks}}<i class="fas fa-check read-icon"></i>{{end}}
|
{{ if $showvisitedlinks}}<i class="fas fa-check read-icon"></i>{{end}}
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
|
|
||||||
{{ define "childs" }}
|
{{ define "childs" }}
|
||||||
{{ range .menu }}
|
{{ range .menu }}
|
||||||
{{ if and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
|
{{ $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
|
||||||
{{else}}
|
{{ if not $hidden }}
|
||||||
{{if not .IsHome}}
|
{{if not .IsHome}}
|
||||||
{{if hasPrefix $.style "h"}}
|
{{if hasPrefix $.style "h"}}
|
||||||
{{$num := sub ( int (trim $.style "h") ) 1 }}
|
{{$num := sub ( int (trim $.style "h") ) 1 }}
|
||||||
|
|
|
@ -210,7 +210,7 @@ textarea:focus, input[type="email"]:focus, input[type="number"]:focus, input[typ
|
||||||
#sidebar ul.topics.searched ul {
|
#sidebar ul.topics.searched ul {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
#sidebar ul.topics ul {
|
#sidebar ul.topics ul, #sidebar ul.topics li.hidden {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#sidebar ul.topics > li > ul > li:last-child {
|
#sidebar ul.topics > li > ul > li:last-child {
|
||||||
|
@ -219,7 +219,9 @@ textarea:focus, input[type="email"]:focus, input[type="number"]:focus, input[typ
|
||||||
#sidebar ul.topics ul ul {
|
#sidebar ul.topics ul ul {
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
#sidebar ul.topics li.parent > ul, #sidebar ul.topics li.active > ul, #sidebar ul.topics li.alwaysopen > ul {
|
#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.alwaysopen > ul {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
#sidebar ul.topics > li > a {
|
#sidebar ul.topics > li > a {
|
||||||
|
|
Loading…
Reference in a new issue