Repo for my website
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.
 
 
 
 

46 lines
1.8 KiB

<div class="pagination">
<div class="pagination__buttons">
{{- if .Paginator.HasPrev }}
<span class="button previous">
<a href="{{ .Paginator.Prev.URL }}">
<span class="button__icon"></span>
<span class="button__text">Previous</span>
</a>
</span>
{{- end }}
{{- with .Paginator }}
{{- $currentPage := .PageNumber }}
{{- $totalPages := .TotalPages }}
{{- if gt $totalPages 1 }}
<ol>
{{- range .Pagers }}
{{- $isFirst := eq .PageNumber 1 }}
{{- $isLast := eq .PageNumber $totalPages }}
{{- $inWindow := and (ge .PageNumber (sub $currentPage 2)) (le .PageNumber (add $currentPage 2)) }}
{{- $showPrevEllipsis := and (gt $currentPage 4) (eq .PageNumber 2) }}
{{- $showNextEllipsis := and (lt $currentPage (sub $totalPages 3)) (eq .PageNumber (sub $totalPages 1)) }}
{{- if or $showPrevEllipsis $showNextEllipsis }}
<li class="button disabled">
<span class="button__text">&hellip;</span>
</li>
{{- else if or $isFirst $isLast $inWindow }}
<li class="button {{- if eq $currentPage .PageNumber }} disabled active{{ end }}">
<a href="{{ .URL }}">
<span class="button__text">{{ .PageNumber }}</span>
</a>
</li>
{{- end }}
{{- end }}
</ol>
{{- end }}
{{- end }}
{{- if .Paginator.HasNext }}
<span class="button next">
<a href="{{ .Paginator.Next.URL }}">
<span class="button__text">Next</span>
<span class="button__icon"></span>
</a>
</span>
{{- end }}
</div>
</div>