38 lines
1.7 KiB
HTML
38 lines
1.7 KiB
HTML
|
{{ $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 -->
|
||
|
{{ if and (ne $pag.PageNumber 1) (ne $pag.PageNumber 2) }}
|
||
|
<li class="page-item"><a href="{{ $pag.First.URL }}" rel="first" class="page-link">«</a></li>
|
||
|
{{ end }}
|
||
|
|
||
|
{{ if $pag.HasPrev }}
|
||
|
<li class="page-item"><a href="{{ $pag.Prev.URL }}" rel="prev" class="page-link">‹</a></li>
|
||
|
{{ end }}
|
||
|
|
||
|
{{ range $pag.Pagers }}
|
||
|
{{ if eq . $pag }} <!-- Current Page -->
|
||
|
<li class="page-item active"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
|
||
|
{{ 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 -->
|
||
|
<li class="page-item"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
|
||
|
{{ else if eq ($.Scratch.Get "dot_rendered") false }} <!-- render skip pages -->
|
||
|
{{ $.Scratch.Set "dot_rendered" true }}
|
||
|
<li class="page-item disabled"><a class="page-link">...</a></li>
|
||
|
{{ end }}
|
||
|
{{ end }}
|
||
|
|
||
|
{{ if $pag.HasNext }}
|
||
|
<li class="page-item"><a href="{{ $pag.Next.URL }}" rel="next" class="page-link">›</a></li>
|
||
|
{{ end }}
|
||
|
|
||
|
<!-- Don't show on last and 2nd last page -->
|
||
|
{{ if and (ne $pag.PageNumber $pag.TotalPages) ((ne $pag.PageNumber (sub $pag.TotalPages 1))) }}
|
||
|
<li class="page-item"><a href="{{ $pag.Last.URL }}" rel="last" class="page-link">»</a></li>
|
||
|
{{ end }}
|
||
|
</ul>
|
||
|
</nav>
|
||
|
{{ end }}
|