67 lines
2.2 KiB
HTML
67 lines
2.2 KiB
HTML
{{ $paginator := .Paginator }}
|
|
{{ $adjacent_links := 2 }}
|
|
{{ $max_links := (add (mul $adjacent_links 2) 1) }}
|
|
{{ $lower_limit := (add $adjacent_links 1) }}
|
|
{{ $upper_limit := (sub $paginator.TotalPages $adjacent_links) }}
|
|
{{ if gt $paginator.TotalPages 1 }}
|
|
|
|
<nav>
|
|
<ul class="pagination">
|
|
{{ if ne $paginator.PageNumber 1 }}
|
|
<li class="page-item">
|
|
<a class="page-link" href="{{ $paginator.First.URL }}">
|
|
<i class="mdi mdi-step-backward-2"></i>
|
|
</a>
|
|
</li>
|
|
{{ end }}
|
|
{{ if $paginator.HasPrev }}
|
|
<li class="page-item">
|
|
<a href="{{ $paginator.Prev.URL }}" class="page-link">
|
|
<i class="mdi mdi-step-backward"></i>
|
|
</a>
|
|
</li>
|
|
{{ end }}
|
|
{{ range $paginator.Pagers }}
|
|
{{ $.Scratch.Set "page_number_flag" false }}
|
|
{{ if gt $paginator.TotalPages $max_links }}
|
|
{{ if le $paginator.PageNumber $lower_limit }}
|
|
{{ if le .PageNumber $max_links }}
|
|
{{ $.Scratch.Set "page_number_flag" true }}
|
|
{{ end }}
|
|
{{ else if ge $paginator.PageNumber $upper_limit }}
|
|
{{ if gt .PageNumber (sub $paginator.TotalPages $max_links) }}
|
|
{{ $.Scratch.Set "page_number_flag" true }}
|
|
{{ end }}
|
|
{{ else }}
|
|
{{ if and ( ge .PageNumber (sub $paginator.PageNumber $adjacent_links) ) ( le .PageNumber (add $paginator.PageNumber $adjacent_links) ) }}
|
|
{{ $.Scratch.Set "page_number_flag" true }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ else }}
|
|
{{ $.Scratch.Set "page_number_flag" true }}
|
|
{{ end }}
|
|
{{ if eq ($.Scratch.Get "page_number_flag") true }}
|
|
<li class="page-item {{ if eq . $paginator }}active{{ end }}">
|
|
<a href="{{ .URL }}" class="page-link">
|
|
{{ .PageNumber }}
|
|
</a>
|
|
</li>
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ if $paginator.HasNext }}
|
|
<li class="page-item">
|
|
<a href="{{ $paginator.Next.URL }}" class="page-link">
|
|
<i class="mdi mdi-step-forward"></i>
|
|
</a>
|
|
</li>
|
|
{{ end }}
|
|
{{ if ne $paginator.PageNumber $paginator.TotalPages }}
|
|
<li class="page-item">
|
|
<a class="page-link" href="{{ $paginator.Last.URL }}">
|
|
<i class="mdi mdi-step-forward-2"></i>
|
|
</a>
|
|
</li>
|
|
{{ end }}
|
|
</ul>
|
|
</nav>
|
|
{{ end }} |