Use pagination variable

main
Elnu 2 years ago
parent 97706c371f
commit 0123220208

@ -1,11 +1,12 @@
{{ define "main" }}
{{ partial "pagination.html" . }}
{{ if eq .Paginator.PageNumber 1 }}
{{ $pagination := .Paginator }}
{{ partial "pagination.html" $pagination }}
{{ if eq $pagination.PageNumber 1 }}
<h1>{{ .Title }}</h1>
{{ partial "content.html" .Content }}
<hr>
{{ end }}
{{ range .Paginator.Pages }}
{{ range $pagination.Pages }}
<article>
<header>
<h2><a href="{{ .RelPermalink }}">{{ partial "content.html" .Title }}</a></h2>
@ -16,5 +17,5 @@
</article>
<br>
{{ end }}
{{ partial "pagination.html" . }}
{{ partial "pagination.html" $pagination }}
{{ end }}

@ -1,6 +1,7 @@
{{ $pag := $.Paginator }}
{{ $pag := . }}
{{ $scratch := newScratch }}
{{ if gt $pag.TotalPages 1 }}
{{ $.Scratch.Set "dot_rendered" false }}
{{ $scratch.Set "dot_rendered" false }}
<nav aria-label="page navigation">
{{ if and (ne $pag.PageNumber 1) (ne $pag.PageNumber 2) }}
<a href="{{ $pag.First.URL }}" rel="first">« First</a>
@ -12,10 +13,10 @@
{{ if eq . $pag }}
{{ .PageNumber }}
{{ else if and (ge .PageNumber (sub $pag.PageNumber 2)) (le .PageNumber (add $pag.PageNumber 2)) }}
{{ $.Scratch.Set "dot_rendered" false }}
{{ $scratch.Set "dot_rendered" false }}
<a href="{{ .URL }}">{{ .PageNumber }}</a>
{{ else if eq ($.Scratch.Get "dot_rendered") false }}
{{ $.Scratch.Set "dot_rendered" true }}
{{ else if eq ($scratch.Get "dot_rendered") false }}
{{ $scratch.Set "dot_rendered" true }}
&hellip;
{{ end }}
{{ end }}