mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-22 23:37:53 +00:00
Use index pages
This commit is contained in:
parent
b8d31039ec
commit
23e40c6b5b
4 changed files with 24 additions and 27 deletions
|
@ -0,0 +1,3 @@
|
|||
{{ partial "header.html" . }}
|
||||
{{ .Content }}
|
||||
{{ partial "footer.html" . }}
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
{{ if .Params.chapter }}
|
||||
{{ if eq .Kind "section" }}
|
||||
</div> <!-- end chapter-->
|
||||
{{ end }}
|
||||
</div>
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<i class="fa fa-bars"></i>
|
||||
</a>
|
||||
</span>
|
||||
{{ if and (not .Params.chapter) (.Params.toc) }}
|
||||
{{ if and (ne .Kind "section") (.Params.toc) }}
|
||||
<span id="toc-menu"><a href=""><i class="fa fa-list-alt"></i></a></span>
|
||||
{{ end }}
|
||||
{{ $type := .Type }}
|
||||
|
@ -67,10 +67,10 @@
|
|||
{{ end }}
|
||||
|
||||
</div>
|
||||
{{ if .Params.chapter }}
|
||||
{{ if eq .Kind "section" }}
|
||||
<div id="chapter">
|
||||
{{ end }}
|
||||
<div id="body-inner">
|
||||
{{ if not .Params.chapter }}
|
||||
<div id="body-inner">
|
||||
{{ if ne .Kind "section" }}
|
||||
<h1>{{.Title}}</h1>
|
||||
{{ end }}
|
||||
|
|
|
@ -12,31 +12,27 @@
|
|||
<div class="highlightable">
|
||||
<ul class="topics">
|
||||
{{ $page := . }}
|
||||
{{ if .Site.Params.menu }}
|
||||
{{ $.Scratch.Set "menuItems" (slice) }}
|
||||
{{ range $i, $key := .Site.Params.menu }}
|
||||
{{ if isset $page.Site.Sections $key }}
|
||||
{{ $.Scratch.Add "menuItems" $key }}
|
||||
{{ else }}
|
||||
<li class="dd-item"><div class="notices warning"><p>
|
||||
{{ printf "Unknown section '%s' found in site menu" $key }}
|
||||
</p></div></li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "menuItems" .Site.Sections }}
|
||||
{{ $.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 }}
|
||||
{{ $menuItems := $.Scratch.Get "menuItems" }}
|
||||
{{ range $i, $key := $menuItems }}
|
||||
{{ if ne $key "" }}
|
||||
|
||||
{{ if not $.Site.Params.menu }}
|
||||
{{ $.Scratch.Set "currentItem" (index $page.Site.Sections $i) }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "currentItem" (index $page.Site.Sections $key) }}
|
||||
{{ $value := (index $page.Site.Sections $key) }}
|
||||
{{ with $index := $.Site.GetPage "section" $key }}
|
||||
{{ if .Title }}
|
||||
{{ $.Scratch.Set "first" $index }}
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set (index $value 0).Page }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ $value := $.Scratch.Get "currentItem" }}
|
||||
{{ $first := (index $value 0).Page }}
|
||||
{{ $first := $.Scratch.Get "first" }}
|
||||
|
||||
<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 }}">
|
||||
|
@ -50,17 +46,15 @@
|
|||
{{ end }}
|
||||
</span>
|
||||
</a>
|
||||
{{ if gt $value.Len 1}}
|
||||
{{ if gt $value.Len 0}}
|
||||
<ul>
|
||||
{{ range $k, $p := $value }}
|
||||
{{ if gt $k 0 }}
|
||||
<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 }}
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
|
|
Loading…
Reference in a new issue