This repository has been archived on 2024-09-02. You can view files and clone it, but cannot push or open issues or pull requests.
hugo-theme-nocolor/layouts/partials/pagination.html
2019-11-20 19:56:22 +01:00

49 lines
1.3 KiB
HTML

{{ $pag := .Paginator }}
<div class="pagination">
<span>Pages:</span>
<ul>
<li>
<a href="{{ $pag.First.URL }}">First</a>
</li>
{{- with $pag.HasPrev }}
{{- if ne $pag.Prev.PageNumber $pag.First.PageNumber }}
{{- $ppage := $pag.Prev }}
{{- with $ppage.HasPrev }}
{{- if ne $ppage.Prev.PageNumber $pag.First.PageNumber }}
<li>
<a href="{{ $ppage.Prev.URL }}">{{ sub $pag.PageNumber 2 }}</a>
</li>
{{- end }}
{{- end }}
<li>
<a href="{{ $ppage.URL }}">{{ sub $pag.PageNumber 1 }}</a>
</li>
{{- end }}
{{- end }}
{{- if and (ne $pag.PageNumber $pag.First.PageNumber) (ne $pag.PageNumber $pag.Last.PageNumber) }}
<li class="selected">
<a href="{{ $pag.URL }}">{{ $pag.PageNumber }}</a>
</li>
{{- end }}
{{- with $pag.HasNext }}
{{- if ne $pag.Next.PageNumber $pag.Last.PageNumber }}
{{- $npage := $pag.Next }}
<li>
<a href="{{ $npage.URL }}">{{ add $pag.PageNumber 1 }}</a>
</li>
{{- with $npage.HasNext }}
{{- if ne $npage.Next.PageNumber $pag.Last.PageNumber }}
<li>
<a href="{{ $npage.Next.URL }}">{{ add $pag.PageNumber 2 }}</a>
</li>
{{- end }}
{{- end }}
{{- end }}
{{- end }}
<li>
<a href="{{ $pag.Last.URL }}">Last</a>
</li>
</ul>
</div>