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--> </div> <!-- end chapter-->
{{ end }} {{ end }}
</div> </div>

View file

@ -47,7 +47,7 @@
<i class="fa fa-bars"></i> <i class="fa fa-bars"></i>
</a> </a>
</span> </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> <span id="toc-menu"><a href=""><i class="fa fa-list-alt"></i></a></span>
{{ end }} {{ end }}
{{ $type := .Type }} {{ $type := .Type }}
@ -67,10 +67,10 @@
{{ end }} {{ end }}
</div> </div>
{{ if .Params.chapter }} {{ if eq .Kind "section" }}
<div id="chapter"> <div id="chapter">
{{ end }} {{ end }}
<div id="body-inner"> <div id="body-inner">
{{ if not .Params.chapter }} {{ if ne .Kind "section" }}
<h1>{{.Title}}</h1> <h1>{{.Title}}</h1>
{{ end }} {{ end }}

View file

@ -12,31 +12,27 @@
<div class="highlightable"> <div class="highlightable">
<ul class="topics"> <ul class="topics">
{{ $page := . }} {{ $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)}} {{ $.Scratch.Set "menuItems" (slice)}}
{{ range $i, $key := .Site.Params.menu }} {{ range $key, $value := sort ($.Scratch.Get "_pages") "Weight" }}
{{ if isset $page.Site.Sections $key }} {{ $.Scratch.Add "menuItems" $value.Section }}
{{ $.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 }}
{{ end }} {{ end }}
{{ $menuItems := $.Scratch.Get "menuItems" }} {{ $menuItems := $.Scratch.Get "menuItems" }}
{{ range $i, $key := $menuItems }} {{ range $i, $key := $menuItems }}
{{ if ne $key "" }} {{ if ne $key "" }}
{{ if not $.Site.Params.menu }} {{ $value := (index $page.Site.Sections $key) }}
{{ $.Scratch.Set "currentItem" (index $page.Site.Sections $i) }} {{ with $index := $.Site.GetPage "section" $key }}
{{ if .Title }}
{{ $.Scratch.Set "first" $index }}
{{ else }} {{ else }}
{{ $.Scratch.Set "currentItem" (index $page.Site.Sections $key) }} {{ $.Scratch.Set (index $value 0).Page }}
{{ end }} {{ end }}
{{ $value := $.Scratch.Get "currentItem" }} {{ end }}
{{ $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 }}"> <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 }}"> <a href="{{ $first.RelPermalink }}">
@ -50,17 +46,15 @@
{{ end }} {{ end }}
</span> </span>
</a> </a>
{{ if gt $value.Len 1}} {{ if gt $value.Len 0}}
<ul> <ul>
{{ range $k, $p := $value }} {{ 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 }}"> <li class="dd-item {{ if eq $page.RelPermalink $p.Page.RelPermalink }}active{{ end }}" data-nav-id="{{ $p.Page.RelPermalink }}">
<a href="{{ $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> <span>{{ $p.Page.Title }} {{ if $page.Site.Params.showVisitedLinks}} <i class="fa fa-check read-icon"> {{ end }} </i></span>
</a> </a>
</li> </li>
{{ end }} {{ end }}
{{ end }}
</ul> </ul>
{{ end }} {{ end }}
</li> </li>