binario/layouts/partials/pagination.html

30 lines
1 KiB
HTML
Raw Normal View History

2018-02-23 12:27:28 +00:00
{{- $pag := $.Paginator }}
{{- if gt $pag.TotalPages 1 }}
<div class="pagination block">
2019-12-02 18:36:02 +00:00
{{- $ellipsed := false }}
{{- $shouldEllipse := false }}
2018-02-23 12:27:28 +00:00
{{- range $pag.Pagers }}
2019-12-02 17:36:31 +00:00
{{- $right := sub .TotalPages .PageNumber }}
{{- $showNumber := or (le .PageNumber 3) (eq $right 0) }}
{{- $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }}
{{- if $showNumber }}
2019-12-02 18:36:02 +00:00
{{- $ellipsed = false }}
{{- $shouldEllipse = false }}
2019-12-02 17:36:31 +00:00
{{- else }}
2019-12-02 18:36:02 +00:00
{{- $shouldEllipse = not $ellipsed }}
{{- $ellipsed = true }}
2019-12-02 17:36:31 +00:00
{{- end }}
{{- if $showNumber }}
{{- if eq . $pag }}
<span class="pagination__item pagination__item--active" data-total="{{ $pag.TotalPages }}">
{{- .PageNumber -}}
</span>
{{- else }}
<a class="pagination__item pagination__item--desktop" href="{{ .URL }}">{{ .PageNumber }}</a>
{{- end }}
2019-12-02 18:36:02 +00:00
{{- else if $shouldEllipse }}
2019-12-02 17:36:31 +00:00
<span class="pagination__item pagination__item--gap">&hellip;</span>
{{- end }}
2018-02-23 12:27:28 +00:00
{{- end }}
</div>
{{- end }}