binario/layouts/partials/pagination.html

29 lines
1.2 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">
{{- $.Scratch.Set "__paginator.ellipsed" false }}
{{- 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 }}
{{- $.Scratch.Set "__paginator.ellipsed" false }}
{{- $.Scratch.Set "__paginator.shouldEllipse" false }}
{{- else }}
{{- $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }}
{{- $.Scratch.Set "__paginator.ellipsed" true }}
{{- 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 }}
{{- else if ($.Scratch.Get "__paginator.shouldEllipse") }}
<span class="pagination__item pagination__item--gap">&hellip;</span>
{{- end }}
2018-02-23 12:27:28 +00:00
{{- end }}
</div>
{{- end }}