Want to contribute? Fork me on Codeberg.org!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

31 lines
1.2 KiB

{{ $pag := . }}
{{ $scratch := newScratch }}
3 years ago
{{ if gt $pag.TotalPages 1 }}
{{ $scratch.Set "dot_rendered" false }}
3 years ago
<nav aria-label="page navigation">
{{ if and (ne $pag.PageNumber 1) (ne $pag.PageNumber 2) }}
<a href="{{ $pag.First.URL }}" rel="first">« First</a>
{{ end }}
{{ if $pag.HasPrev }}
<a href="{{ $pag.Prev.URL }}" rel="prev" class="page-link"> Prev</a>
{{ end }}
{{ range $pag.Pagers }}
{{ if eq . $pag }}
{{ .PageNumber }}
{{ else if and (ge .PageNumber (sub $pag.PageNumber 2)) (le .PageNumber (add $pag.PageNumber 2)) }}
{{ $scratch.Set "dot_rendered" false }}
3 years ago
<a href="{{ .URL }}">{{ .PageNumber }}</a>
{{ else if eq ($scratch.Get "dot_rendered") false }}
{{ $scratch.Set "dot_rendered" true }}
3 years ago
&hellip;
{{ end }}
{{ end }}
{{ if $pag.HasNext }}
<a href="{{ $pag.Next.URL }}" rel="next" class="page-link">Next </a>
{{ end }}
{{ if and (ne $pag.PageNumber $pag.TotalPages) ((ne $pag.PageNumber (sub $pag.TotalPages 1))) }}
<a href="{{ $pag.Last.URL }}" rel="last" class="page-link">Last »</a>
{{ end }}
</nav>
{{ end }}