34 lines
1.1 KiB
HTML
34 lines
1.1 KiB
HTML
|
{{- $paginator := . -}}
|
||
|
|
||
|
{{- if gt $paginator.TotalPages 1 -}}
|
||
|
|
||
|
{{- $pageIndex := $paginator.PageNumber -}}
|
||
|
{{- $totalPages := $paginator.TotalPages -}}
|
||
|
{{- $cols := 5.0 -}}
|
||
|
{{- $rows := math.Ceil (div $totalPages $cols) -}}
|
||
|
{{- $row := math.Ceil (div $pageIndex $cols) -}}
|
||
|
{{- $startPage := sub (mul $row $cols) $cols -}}
|
||
|
{{- $endPage := add $startPage $cols -}}
|
||
|
|
||
|
<div class="pagination">
|
||
|
<ul>
|
||
|
{{- if gt $row 1 -}}
|
||
|
<li><a href="{{- $paginator.Prev.URL -}}" class="previous_page">«</a></li>
|
||
|
{{- end -}}
|
||
|
|
||
|
{{- range $paginator.Pagers -}}
|
||
|
{{- if and (gt .PageNumber $startPage) (le .PageNumber $endPage) -}}
|
||
|
{{- $active := "" -}}
|
||
|
{{- if eq .PageNumber $paginator.PageNumber -}}
|
||
|
{{- $active = "active" -}}
|
||
|
{{- end -}}
|
||
|
<li><a class="{{- $active -}}" href="{{- .URL -}}">{{- .PageNumber -}}</a></li>
|
||
|
{{- end -}}
|
||
|
{{- end -}}
|
||
|
|
||
|
{{- if lt $row $rows -}}
|
||
|
<li><a href="{{- $paginator.Next.URL -}}" class="next_page">»</a></li>
|
||
|
{{- end -}}
|
||
|
</ul>
|
||
|
</div>
|
||
|
{{- end -}}
|