Merge pull request #136 from life1347/avoid-print-uncessary-sidelist-items

Avoid printing unnecessary sections in sidelist
This commit is contained in:
Mehedi Sharif Titas 2020-03-11 14:56:24 +06:00 committed by GitHub
commit afc467935f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 34 deletions

View file

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

View file

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