Use pagination variable

main
Elnu 2 years ago
parent 97706c371f
commit 0123220208

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

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