2022-11-13 20:52:45 +01:00
|
|
|
{{ $pag := $.Paginator }}
|
|
|
|
{{ if gt $pag.TotalPages 1 }}
|
|
|
|
{{ $.Scratch.Set "dot_rendered" false }}
|
|
|
|
<nav aria-label="page navigation">
|
|
|
|
<ul class="pagination">
|
|
|
|
<!-- Don't show on 1st and 2nd page -->
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- if and (ne $pag.PageNumber 1) (ne $pag.PageNumber 2) -}}
|
2022-11-13 20:52:45 +01:00
|
|
|
<li class="page-item"><a href="{{ $pag.First.URL }}" rel="first" class="page-link">«</a></li>
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- end -}}
|
2022-11-13 20:52:45 +01:00
|
|
|
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- if $pag.HasPrev }}
|
2022-11-13 20:52:45 +01:00
|
|
|
<li class="page-item"><a href="{{ $pag.Prev.URL }}" rel="prev" class="page-link">‹</a></li>
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- end -}}
|
2022-11-13 20:52:45 +01:00
|
|
|
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- range $pag.Pagers -}}
|
|
|
|
{{- if eq . $pag -}} <!-- Current Page -->
|
2022-11-13 20:52:45 +01:00
|
|
|
<li class="page-item active"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- else if and (ge .PageNumber (sub $pag.PageNumber 2)) (le .PageNumber (add $pag.PageNumber 2)) -}}
|
|
|
|
{{- $.Scratch.Set "dot_rendered" false }} <!-- Render prev 2 page and next 2 pages -->
|
2022-11-13 20:52:45 +01:00
|
|
|
<li class="page-item"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- else if eq ($.Scratch.Get "dot_rendered") false }} <!-- render skip pages -->
|
|
|
|
{{- $.Scratch.Set "dot_rendered" true }}
|
2022-11-13 20:52:45 +01:00
|
|
|
<li class="page-item disabled"><a class="page-link">...</a></li>
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- end }}
|
|
|
|
{{- end -}}
|
2022-11-13 20:52:45 +01:00
|
|
|
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- if $pag.HasNext }}
|
2022-11-13 20:52:45 +01:00
|
|
|
<li class="page-item"><a href="{{ $pag.Next.URL }}" rel="next" class="page-link">›</a></li>
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- end -}}
|
2022-11-13 20:52:45 +01:00
|
|
|
|
|
|
|
<!-- Don't show on last and 2nd last page -->
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- if and (ne $pag.PageNumber $pag.TotalPages) ((ne $pag.PageNumber (sub $pag.TotalPages 1))) }}
|
2022-11-13 20:52:45 +01:00
|
|
|
<li class="page-item"><a href="{{ $pag.Last.URL }}" rel="last" class="page-link">»</a></li>
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- end }}
|
2022-11-13 20:52:45 +01:00
|
|
|
</ul>
|
|
|
|
</nav>
|
2023-01-22 00:47:23 +01:00
|
|
|
{{- end }}
|