From d3f70bd846124b9f83528caacc2094d951043ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Thu, 26 Aug 2021 23:26:05 +0200 Subject: [PATCH] menu: show hidden pages if accessed directly #60 --- exampleSite/content/yours/_index.en.md | 1 + layouts/partials/footer.html | 3 ++- layouts/partials/menu.html | 25 +++++++------------------ layouts/shortcodes/children.html | 4 ++-- static/css/theme.css | 6 ++++-- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/exampleSite/content/yours/_index.en.md b/exampleSite/content/yours/_index.en.md index 12644ba644..855d6c469e 100644 --- a/exampleSite/content/yours/_index.en.md +++ b/exampleSite/content/yours/_index.en.md @@ -1,5 +1,6 @@ +++ chapter = true +hidden = true title = "This could be yours" weight = 4 +++ diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 54e588e069..1d7567368c 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -13,7 +13,8 @@ {{ define "menu-nextprev" }} {{$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 }} {{ $currentNode.Scratch.Set "NextPageOK" "OK" }} {{ $currentNode.Scratch.Set "prevPage" ($currentNode.Scratch.Get "prevPageTmp") }} diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index de7e940cad..859a3bb63b 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -105,14 +105,11 @@ {{ $alwaysopen := .alwaysopen }} {{ with $currentNode.File }}{{ $currentFileUniqueID = .UniqueID }}{{ end }} {{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}} {{ $currentAlwaysopen := .Params.alwaysopen | default $alwaysopen }} -
  • +
  • {{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }} {{ if $showvisitedlinks}}{{end}} @@ -126,25 +123,17 @@ {{if eq .Site.Params.ordersectionsby "title"}} {{ range $pages.ByTitle }} - {{ if and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }} - {{else}} - {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" true}} - {{end}} + {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" true}} {{ end }} {{else}} {{ range $pages.ByWeight }} - {{ if and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }} - {{else}} - {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" true}} - {{end}} + {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" true}} {{ end }} {{end}}
  • - {{else if and (not .Params.hidden) (ne .Title "") }} -
  • + {{else}} +
  • {{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }} {{ if $showvisitedlinks}}{{end}} diff --git a/layouts/shortcodes/children.html b/layouts/shortcodes/children.html index 44eec093ac..d1c4a24d7e 100644 --- a/layouts/shortcodes/children.html +++ b/layouts/shortcodes/children.html @@ -38,8 +38,8 @@ {{ define "childs" }} {{ range .menu }} - {{ if and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }} - {{else}} + {{ $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }} + {{ if not $hidden }} {{if not .IsHome}} {{if hasPrefix $.style "h"}} {{$num := sub ( int (trim $.style "h") ) 1 }} diff --git a/static/css/theme.css b/static/css/theme.css index d4f030d2fb..531a80805c 100644 --- a/static/css/theme.css +++ b/static/css/theme.css @@ -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 ul, #sidebar ul.topics li.hidden { display: none; } #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 { 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; } #sidebar ul.topics > li > a {