Avoid printing unnecessary sections in sidelist

This commit is contained in:
Ta-Ching Chen 2020-03-11 16:29:33 +08:00
parent 8d44df6fb9
commit f5b7ee0a93
2 changed files with 16 additions and 34 deletions

View file

@ -763,7 +763,7 @@ tbody {
/* side list */ /* side list */
.sidelist { .sidelist {
display: none; display: block;
} }
li.sidelist>a { li.sidelist>a {
@ -776,18 +776,6 @@ li.sidelist li a {
margin: 0; margin: 0;
} }
.sidelist.parent {
display: block;
}
.sidelist.parent::before {
display: none;
}
.sidelist.parent.active::before {
display: block;
}
.sidelist li.sidelist { .sidelist li.sidelist {
display: block; display: block;
} }
@ -923,4 +911,4 @@ code {
z-index: 1; z-index: 1;
left: -15px; left: -15px;
top: -3px; top: -3px;
} }

View file

@ -8,8 +8,10 @@
{{ $currentNode := . }} {{ $currentNode := . }}
<a class="d-block h4 back-btn" href="{{ .Site.BaseURL | relLangURL }}">{{ i18n "Back-home"}}</a> <a class="d-block h4 back-btn" href="{{ .Site.BaseURL | relLangURL }}">{{ i18n "Back-home"}}</a>
{{range .Site.Home.Sections.ByWeight}} {{range .Site.Home.Sections.ByWeight}}
{{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode}} {{ if eq . $currentNode.FirstSection }} {{/* print current section only */}}
{{end}} {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode}}
{{ end }}
{{ end }}
</ul> </ul>
</div> </div>
</div> </div>
@ -79,29 +81,21 @@
{{with .sect}} {{with .sect}}
{{safeHTML .Params.head}} {{safeHTML .Params.head}}
<li data-nav-id="{{.Permalink}}" title="{{.Title}}" class="sidelist <li data-nav-id="{{.Permalink}}" title="{{.Title}}" class="sidelist
{{if .IsAncestor $currentNode }}parent{{end}} {{if eq .File.UniqueID $currentNode.File.UniqueID}}active{{end}}">
{{if eq .File.UniqueID $currentNode.File.UniqueID}}active{{end}}
{{if .Params.alwaysopen}}parent{{end}}">
<a href="{{.Permalink}}"> <a href="{{.Permalink}}">
{{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}} {{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}}
</a> </a>
{{ $numberOfPages := (add (len .Pages) (len .Sections)) }} {{ $numberOfPages := (add (len .Pages) (len .Sections)) }}
{{ if ne $numberOfPages 0 }} {{ if ne $numberOfPages 0 }}
<ul> <ul>
{{ $currentNode.Scratch.Set "pages" .Pages }} {{ range .Pages.ByWeight }}
{{ if .Sections}} {{ if and .Params.hidden (not $.showhidden) }}
{{ $currentNode.Scratch.Set "pages" (.Pages | union .Sections) }} {{else}}
{{end}} {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode }}
{{ $pages := ($currentNode.Scratch.Get "pages") }} {{end}}
{{end}}
{{ range $pages.ByWeight }} </ul>
{{ if and .Params.hidden (not $.showhidden) }} {{ end }}
{{else}}
{{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode }}
{{end}}
{{end}}
</ul>
</li> </li>
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }}