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.

31 lines
1.2 KiB

{{ $pag := . }}
{{ $scratch := newScratch }}
2 years ago
{{ if gt $pag.TotalPages 1 }}
{{ $scratch.Set "dot_rendered" false }}
2 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 }}
2 years ago
<a href="{{ .URL }}">{{ .PageNumber }}</a>
{{ else if eq ($scratch.Get "dot_rendered") false }}
{{ $scratch.Set "dot_rendered" true }}
2 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 }}