hugo-theme-relearn/layouts/partials/menu.html

80 lines
2.8 KiB
HTML
Raw Normal View History

<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">
{{ $page := . }}
2017-03-13 23:10:33 +00:00
{{ if $.Site.Params.menu }}
{{ $.Scratch.Set "menuItems" $.Site.Params.menu }}
{{ else }}
{{ $.Scratch.Set "_pages" (slice) }}
{{ range $key, $value := .Site.Sections }}
{{ $.Scratch.Add "_pages" ($.Site.GetPage "section" $key) }}
{{ 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 "" }}
2017-03-13 22:07:40 +00:00
{{ $value := (index $page.Site.Sections $key) }}
2017-03-13 23:10:33 +00:00
{{ $.Scratch.Set "_value" $value }}
2017-03-13 22:07:40 +00:00
{{ with $index := $.Site.GetPage "section" $key }}
2017-03-13 23:10:33 +00:00
{{ if .Content }}
2017-03-13 22:07:40 +00:00
{{ $.Scratch.Set "first" $index }}
{{ else }}
2017-03-13 23:10:33 +00:00
{{ $.Scratch.Set "first" (index $value 0).Page }}
{{ $.Scratch.Set "_value" (after 1 $value) }}
2017-03-13 22:07:40 +00:00
{{ end }}
{{ end }}
2017-03-13 22:07:40 +00:00
{{ $first := $.Scratch.Get "first" }}
2017-03-13 23:10:33 +00:00
{{ $value := $.Scratch.Get "_value" }}
<li class="dd-item {{ if eq $page.RelPermalink $first.RelPermalink }}active{{ end }} {{if in $page.RelPermalink $first.RelPermalink }}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 $page.Site.Params.showVisitedLinks}}
2016-05-23 20:18:57 +00:00
<i class="fa fa-check read-icon"></i>
{{ end }}
</span>
</a>
2017-03-13 22:07:40 +00:00
{{ if gt $value.Len 0}}
<ul>
{{ range $k, $p := $value }}
<li class="dd-item {{ if eq $page.RelPermalink $p.Page.RelPermalink }}active{{ end }}" data-nav-id="{{ $p.Page.RelPermalink }}">
<a href="{{ $p.Page.RelPermalink }}">
<span>{{ $p.Page.Title }} {{ if $page.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}}
2016-05-23 20:18:57 +00:00
<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>