From c81bf82ced33dfa8fa838ea5d743548983679d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Thu, 26 Aug 2021 22:19:52 +0200 Subject: [PATCH] menu: allow empty ul This simplyfies code, as of now it is only necessary to tag the ul with classes and let the CSS do all the heavy lifting. Care was taken, to not mess up layout when a ul ends up with all its li hidden. --- layouts/partials/menu.html | 53 ++++++++++++++++++++------------------ static/css/theme.css | 6 +++-- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index 957dba4d06..de7e940cad 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -108,40 +108,43 @@ {{if and .IsSection (or (and (not .Params.hidden) (ne .Title "")) $.showhidden )}} {{safeHTML .Params.head}} {{ $currentAlwaysopen := .Params.alwaysopen | default $alwaysopen }} -
  • +
  • {{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }} {{ if $showvisitedlinks}}{{end}} - {{ $numberOfPages := (add (len (where (where .Pages "Params.hidden" "ne" true ) "Title" "ne" "" )) (len (where (where .Sections "Params.hidden" "ne" true ) "Title" "ne" "" )) ) }} - {{ if ne $numberOfPages 0 }} -
  • {{else if and (not .Params.hidden) (ne .Title "") }} -
  • +
  • {{ partial "menu-pre.html" . }}{{or .Params.menuTitle .LinkTitle .Title}}{{ partial "menu-post.html" . }} {{ if $showvisitedlinks}}{{end}} diff --git a/static/css/theme.css b/static/css/theme.css index 4ff9e37e79..d4f030d2fb 100644 --- a/static/css/theme.css +++ b/static/css/theme.css @@ -212,12 +212,14 @@ textarea:focus, input[type="email"]:focus, input[type="number"]:focus, input[typ } #sidebar ul.topics ul { display: none; +} +#sidebar ul.topics > li > ul > li:last-child { padding-bottom: 1rem; } #sidebar ul.topics ul ul { padding-bottom: 0; } -#sidebar ul.topics li.parent > ul, #sidebar ul.topics li.active > ul { +#sidebar ul.topics li.parent > ul, #sidebar ul.topics li.active > ul, #sidebar ul.topics li.alwaysopen > ul { display: block; } #sidebar ul.topics > li > a { @@ -231,7 +233,7 @@ textarea:focus, input[type="email"]:focus, input[type="number"]:focus, input[typ #sidebar ul.topics > li > a .fa { margin-top: 9px; } -#sidebar ul.topics > li.parent, #sidebar ul.topics > li.active { +#sidebar ul.topics > li.parent { background: #251f29; margin-left: -1rem; margin-right: -1rem;