2018-05-04 15:53:56 +00:00
|
|
|
{{ $pag := $.Paginator }}
|
|
|
|
{{ if gt $pag.TotalPages 1 }}
|
|
|
|
<ul class="pagination">
|
|
|
|
{{ with $pag.First }}
|
2018-06-26 09:31:17 +00:00
|
|
|
<li class="page-item">
|
|
|
|
<a href="{{ .URL }}" class="page-link" aria-label="First"><span aria-hidden="true">««</span></a>
|
2018-05-04 15:53:56 +00:00
|
|
|
</li>
|
|
|
|
{{ end }}
|
2018-06-26 09:31:17 +00:00
|
|
|
<li class="page-item{{ if not $pag.HasPrev }} disabled{{ end }}">
|
|
|
|
<a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" class="page-link" aria-label="Previous"><span aria-hidden="true">«</span></a>
|
2018-05-04 15:53:56 +00:00
|
|
|
</li>
|
|
|
|
{{ $.Scratch.Set "__paginator.ellipsed" false }}
|
|
|
|
{{ range $pag.Pagers }}
|
|
|
|
{{ $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 }}
|
2018-06-26 09:31:17 +00:00
|
|
|
<li class="page-item{{ if eq . $pag }} active{{ end }}"><a class="page-link" href="{{ .URL }}">{{ .PageNumber }}</a></li>
|
2018-05-04 15:53:56 +00:00
|
|
|
{{ else if ($.Scratch.Get "__paginator.shouldEllipse") }}
|
2018-06-26 09:31:17 +00:00
|
|
|
<li class="page-item disabled"><span aria-hidden="true"> … </span></li>
|
2018-05-04 15:53:56 +00:00
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|
2018-06-26 09:31:17 +00:00
|
|
|
<li class="page-item{{ if not $pag.HasNext }} disabled{{ end }}">
|
|
|
|
<a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}" class="page-link" aria-label="Next"><span aria-hidden="true">»</span></a>
|
2018-05-04 15:53:56 +00:00
|
|
|
</li>
|
|
|
|
{{ with $pag.Last }}
|
2018-06-26 09:31:17 +00:00
|
|
|
<li class="page-item">
|
|
|
|
<a href="{{ .URL }}" class="page-link" aria-label="Last"><span aria-hidden="true">»»</span></a>
|
2018-05-04 15:53:56 +00:00
|
|
|
</li>
|
|
|
|
{{ end }}
|
|
|
|
</ul>
|
|
|
|
{{ end }}
|