Files
personal-website/layouts/partials/pagination.html
T
2023-11-21 17:40:40 +01:00

29 lines
1.1 KiB
HTML

{{ $paginator := .Paginator }}
{{ if gt $paginator.TotalPages 1 }}
<div class="pagination">
<a class="first {{ if eq $paginator.PageNumber $paginator.First.PageNumber }} active {{ end }}" href="{{ $paginator.First.URL }}">
{{ $paginator.First.PageNumber }}
</a>
{{ with $paginator.HasPrev }}
<a href="{{ $paginator.Prev.URL }}">
«
</a>
{{ end }}
{{ range $index, $pager := $paginator.Pagers }}
{{ with and (ne $index 0) (ne $index (sub (len $paginator.Pagers) 1)) }}
<a class="{{ if eq $pager $paginator }} active {{ end }}" href="{{ $pager.URL }}">
{{ $pager.PageNumber }}
</a>
{{ end }}
{{ end }}
{{ with $paginator.HasNext }}
<a href="{{ $paginator.Next.URL }}">
»
</a>
{{ end }}
<a class="last {{ if eq $paginator.PageNumber $paginator.Last.PageNumber }} active {{ end }}" href="{{ $paginator.Last.URL }}">
{{ $paginator.Last.PageNumber }}
</a>
</div>
{{ end }}