mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-19 03:10:24 +00:00
Merge branch 'use-index-pages' of https://github.com/lierdakil/hugo-theme-learn
This commit is contained in:
commit
d754216d09
6 changed files with 82 additions and 34 deletions
|
@ -1,9 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Some Chapter title"
|
title: "Some Chapter title"
|
||||||
weight: 0
|
weight: 0
|
||||||
prev: /prev/path
|
|
||||||
next: /next/path
|
|
||||||
chapter: true
|
|
||||||
icon: "<b>X. </b>" # HTML code as prefix in the menu
|
icon: "<b>X. </b>" # HTML code as prefix in the menu
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
---
|
---
|
||||||
title: "Some Title"
|
title: "Some Title"
|
||||||
weight: 5
|
weight: 5
|
||||||
prev: /prev/path
|
|
||||||
next: /next/path
|
|
||||||
toc: true
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
{{ partial "header.html" . }}
|
||||||
|
{{ if .Content }}
|
||||||
|
{{ .Content }}
|
||||||
|
{{ else }}
|
||||||
|
{{ with (index (index .Site.Sections .Section) 0) }}
|
||||||
|
{{ .Page.Content }}
|
||||||
|
{{ $.Scratch.Set "uniqueId" .Page.UniqueID }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ partial "footer.html" . }}
|
|
@ -1,14 +1,55 @@
|
||||||
|
|
||||||
{{ if .Params.chapter }}
|
{{ $isChapter := or (eq .Kind "section") (.Params.chapter)}}
|
||||||
|
{{ if $isChapter }}
|
||||||
</div> <!-- end chapter-->
|
</div> <!-- end chapter-->
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{ if $.Site.Params.autoNav }}
|
||||||
|
{{ $.Scratch.Set "_sectionpages" (slice) }}
|
||||||
|
{{ if $.Site.Params.menu }}
|
||||||
|
{{ range $sname := $.Site.Params.menu }}
|
||||||
|
{{ $.Scratch.Add "_sectionpages" ($.Site.GetPage "section" $sname) }}
|
||||||
|
{{ end }}
|
||||||
|
{{ else }}
|
||||||
|
{{ range $sname, $spages := .Site.Sections }}
|
||||||
|
{{ $.Scratch.Add "_sectionpages" ($.Site.GetPage "section" $sname) }}
|
||||||
|
{{ end }}
|
||||||
|
{{ $.Scratch.Set "_sectionpages" (sort ($.Scratch.Get "_sectionpages") "Weight") }}
|
||||||
|
{{ end }}
|
||||||
|
{{ $.Scratch.Set "_allpages" (slice) }}
|
||||||
|
{{ range $.Scratch.Get "_sectionpages" }}
|
||||||
|
{{ if .Content }}
|
||||||
|
{{ $.Scratch.Add "_allpages" . }}
|
||||||
|
{{ end }}
|
||||||
|
{{ range index $.Site.Sections .Section }}
|
||||||
|
{{ $.Scratch.Add "_allpages" .Page }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
{{ $Site := .Site }}
|
{{ if $.Site.Params.autoNav }}
|
||||||
{{ with .Params.prev }}<a class="nav nav-prev" href="{{ $Site.BaseURL }}{{ . }}"> <i class="fa fa-chevron-left"></i></a>{{ end }}
|
{{ $allpages := $.Scratch.Get "_allpages" }}
|
||||||
{{ with .Params.next }}<a class="nav nav-next" href="{{ $Site.BaseURL }}{{ . }}" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>{{ end }}
|
{{ range $index, $element := $allpages }}
|
||||||
|
{{ $uniqueid := ($.Scratch.Get "uniqueId" | default $.UniqueID ) }}
|
||||||
|
{{if eq $element.UniqueID $uniqueid }}
|
||||||
|
{{ if not (isset $.Params "prev") }}
|
||||||
|
{{ with index $allpages (sub $index 1) }}
|
||||||
|
<a class="nav nav-prev" href="{{ $.Site.BaseURL }}{{ .URL }}"> <i class="fa fa-chevron-left"></i></a>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ if not (isset $.Params "next") }}
|
||||||
|
{{ with index $allpages (add $index 1) }}
|
||||||
|
<a class="nav nav-next" href="{{ $.Site.BaseURL }}{{ .URL }}" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
{{ with .Params.prev }}<a class="nav nav-prev" href="{{ $.Site.BaseURL }}{{ . }}"> <i class="fa fa-chevron-left"></i></a>{{ end }}
|
||||||
|
{{ with .Params.next }}<a class="nav nav-next" href="{{ $.Site.BaseURL }}{{ . }}" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
{{ partial "style.html" . }}
|
{{ partial "style.html" . }}
|
||||||
</head>
|
</head>
|
||||||
<body class="" data-url="{{ .RelPermalink }}">
|
<body class="" data-url="{{ .RelPermalink }}">
|
||||||
|
{{ $isChapter := or (eq .Kind "section") (.Params.chapter)}}
|
||||||
{{ partial "menu.html" . }}
|
{{ partial "menu.html" . }}
|
||||||
<section id="body">
|
<section id="body">
|
||||||
<div id="overlay"></div>
|
<div id="overlay"></div>
|
||||||
|
@ -47,7 +48,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 (not $isChapter) (.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 +68,10 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{{ if .Params.chapter }}
|
{{ if $isChapter }}
|
||||||
<div id="chapter">
|
<div id="chapter">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<div id="body-inner">
|
<div id="body-inner">
|
||||||
{{ if not .Params.chapter }}
|
{{ if not $isChapter }}
|
||||||
<h1>{{.Title}}</h1>
|
<h1>{{.Title}}</h1>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -12,31 +12,34 @@
|
||||||
<div class="highlightable">
|
<div class="highlightable">
|
||||||
<ul class="topics">
|
<ul class="topics">
|
||||||
{{ $page := . }}
|
{{ $page := . }}
|
||||||
{{ if .Site.Params.menu }}
|
{{ 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)}}
|
{{ $.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 }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
|
||||||
{{ $.Scratch.Set "menuItems" .Site.Sections }}
|
|
||||||
{{ 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) }}
|
{{ $.Scratch.Set "_value" $value }}
|
||||||
|
{{ with $index := $.Site.GetPage "section" $key }}
|
||||||
|
{{ if .Content }}
|
||||||
|
{{ $.Scratch.Set "first" $index }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $.Scratch.Set "currentItem" (index $page.Site.Sections $key) }}
|
{{ $.Scratch.Set "first" (index $value 0).Page }}
|
||||||
|
{{ $.Scratch.Set "_value" (after 1 $value) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ $value := $.Scratch.Get "currentItem" }}
|
{{ end }}
|
||||||
{{ $first := (index $value 0).Page }}
|
{{ $first := $.Scratch.Get "first" }}
|
||||||
|
{{ $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 }}">
|
<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 +53,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>
|
||||||
|
|
Loading…
Reference in a new issue