mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +00:00
7aa1e70638
* fix menu ordering when mixing chapters and non-chapters * allow for `chapter` type override in `_index` pages * fix breadcrumbs * fix some crashes with empty categories * use page context in list.html (to avoid setting uniqueid in scratch) * use UniqueID instead of relative links for page identification
87 lines
3 KiB
HTML
87 lines
3 KiB
HTML
<nav id="sidebar">
|
|
<div id="header-wrapper">
|
|
<div id="header">
|
|
{{ partial "logo.html" . }}
|
|
</div>
|
|
{{ if .Site.Params.search }}
|
|
{{ partial "search.html" . }}
|
|
{{ end }}
|
|
</div>
|
|
|
|
|
|
<div class="highlightable">
|
|
<ul class="topics">
|
|
{{ if $.Site.Params.menu }}
|
|
{{ $.Scratch.Set "menuItems" $.Site.Params.menu }}
|
|
{{ else }}
|
|
{{ $.Scratch.Set "_pages" (slice) }}
|
|
{{ range $key, $value := .Site.Sections }}
|
|
{{ $sectionPage := $.Site.GetPage "section" $key }}
|
|
{{ if $sectionPage.Content }}
|
|
{{ $.Scratch.Add "_pages" $sectionPage }}
|
|
{{ else if gt $value.Len 0 }}
|
|
{{ $.Scratch.Add "_pages" (index $value 0).Page }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ $.Scratch.Set "menuItems" (slice)}}
|
|
{{ range $key, $value := sort ($.Scratch.Get "_pages") "Weight" }}
|
|
{{ $.Scratch.Add "menuItems" $value.Section }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ $menuItems := $.Scratch.Get "menuItems" }}
|
|
{{ range $i, $key := $menuItems }}
|
|
{{ if ne $key "" }}
|
|
|
|
{{ $value := (index $.Site.Sections $key) }}
|
|
{{ $.Scratch.Set "_value" $value }}
|
|
{{ with $index := $.Site.GetPage "section" $key }}
|
|
{{ if .Content }}
|
|
{{ $.Scratch.Set "first" $index }}
|
|
{{ else if gt $value.Len 0}}
|
|
{{ $.Scratch.Set "first" (index $value 0).Page }}
|
|
{{ if gt $value.Len 1 }}
|
|
{{ $.Scratch.Set "_value" (after 1 $value) }}
|
|
{{ else }}
|
|
{{ $.Scratch.Set "_value" nil }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ $first := $.Scratch.Get "first" }}
|
|
{{ $value := $.Scratch.Get "_value" }}
|
|
|
|
<li class="dd-item {{ if eq $.UniqueID $first.UniqueID }}active{{ end }} {{if eq $.Section $first.Section }}parent{{ end }}" data-nav-id="{{ $first.RelPermalink }}">
|
|
<a href="{{ $first.RelPermalink }}">
|
|
<span>
|
|
{{ if isset $first.Params "icon" }}
|
|
{{ printf $first.Params.icon | safeHTML }}
|
|
{{ end }}
|
|
{{ $first.Title }}
|
|
{{ if $.Site.Params.showVisitedLinks}}
|
|
<i class="fa fa-check read-icon"></i>
|
|
{{ end }}
|
|
</span>
|
|
</a>
|
|
{{ if gt $value.Len 0}}
|
|
<ul>
|
|
{{ range $k, $p := $value }}
|
|
<li class="dd-item {{ if eq $.UniqueID $p.Page.UniqueID }}active{{ end }}" data-nav-id="{{ $p.Page.RelPermalink }}">
|
|
<a href="{{ $p.Page.RelPermalink }}">
|
|
<span>{{ $p.Page.Title }} {{ if $.Site.Params.showVisitedLinks}} <i class="fa fa-check read-icon"> {{ end }} </i></span>
|
|
</a>
|
|
</li>
|
|
{{ end }}
|
|
</ul>
|
|
{{ end }}
|
|
</li>
|
|
{{ end }}
|
|
{{ end }}
|
|
</ul>
|
|
<hr>
|
|
{{ if .Site.Params.showVisitedLinks}}
|
|
<a class="padding" href="#" data-clear-history-toggle=""><i class="fa fa-fw fa-history"></i> Clear History</a>
|
|
{{ end }}
|
|
<section id="footer">
|
|
{{ partial "menu-footer.html" . }}
|
|
</section>
|
|
</div>
|
|
</nav>
|