Want to contribute? Fork me on Codeberg.org!
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
sakura-hugo-theme/layouts/partials/pagination.html

30 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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