mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
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.
This commit is contained in:
parent
43e600bc0c
commit
c81bf82ced
2 changed files with 32 additions and 27 deletions
|
@ -108,13 +108,15 @@
|
|||
{{if and .IsSection (or (and (not .Params.hidden) (ne .Title "")) $.showhidden )}}
|
||||
{{safeHTML .Params.head}}
|
||||
{{ $currentAlwaysopen := .Params.alwaysopen | default $alwaysopen }}
|
||||
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item{{if eq .File.UniqueID $currentFileUniqueID}} active{{else if .IsAncestor $currentNode }} parent{{else if $currentAlwaysopen}} parent{{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}}
|
||||
</a>
|
||||
{{ $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 }}
|
||||
<ul>
|
||||
{{ $currentNode.Scratch.Set "pages" .Pages }}
|
||||
{{ if .Sections}}
|
||||
|
@ -138,10 +140,11 @@
|
|||
{{ end }}
|
||||
{{end}}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{else if and (not .Params.hidden) (ne .Title "") }}
|
||||
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item{{if eq .File.UniqueID $currentFileUniqueID}} active{{end}}">
|
||||
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item
|
||||
{{if eq .File.UniqueID $currentFileUniqueID}} active{{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}}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue