Use index pages

This commit is contained in:
Nikolay Yakimov 2017-03-14 01:07:40 +03:00
parent b8d31039ec
commit 23e40c6b5b
No known key found for this signature in database
GPG key ID: 8E9303568F9B9650
4 changed files with 24 additions and 27 deletions

View file

@ -0,0 +1,3 @@
{{ partial "header.html" . }}
{{ .Content }}
{{ partial "footer.html" . }}

View file

@ -1,5 +1,5 @@
{{ if .Params.chapter }}
{{ if eq .Kind "section" }}
</div> <!-- end chapter-->
{{ end }}
</div>

View file

@ -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 }}
{{ if ne .Kind "section" }}
<h1>{{.Title}}</h1>
{{ end }}

View file

@ -12,31 +12,27 @@
<div class="highlightable">
<ul class="topics">
{{ $page := . }}
{{ if .Site.Params.menu }}
{{ $.Scratch.Set "_pages" (slice) }}
{{ range $key, $value := .Site.Sections }}
{{ $.Scratch.Add "_pages" ($.Site.GetPage "section" $key) }}
{{ end }}
{{ $.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 }}
{{ 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) }}
{{ $value := (index $page.Site.Sections $key) }}
{{ with $index := $.Site.GetPage "section" $key }}
{{ if .Title }}
{{ $.Scratch.Set "first" $index }}
{{ else }}
{{ $.Scratch.Set "currentItem" (index $page.Site.Sections $key) }}
{{ $.Scratch.Set (index $value 0).Page }}
{{ end }}
{{ $value := $.Scratch.Get "currentItem" }}
{{ $first := (index $value 0).Page }}
{{ end }}
{{ $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>