Rework pagination template to work with Bulma and remove unecessery stuff
parent
37834a6df6
commit
9c486c8331
|
@ -1,21 +1,16 @@
|
||||||
{{ $pag := $.Paginator }}
|
{{ $pag := $.Paginator }}
|
||||||
{{ if gt $pag.TotalPages 1 -}}
|
{{ if gt $pag.TotalPages 1 -}}
|
||||||
<ul class="pagination">
|
<nav class="pagination is-centered" role="navigation" aria-label="pagination">
|
||||||
{{ with $pag.First -}}
|
{{ with $pag.First -}}
|
||||||
<li class="page-item">
|
<ul class="pagination-list">
|
||||||
<a href="{{ .URL }}" class="page-link" aria-label="First"><span aria-hidden="true">««</span></a>
|
|
||||||
</li>
|
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
<li class="page-item{{ if not $pag.HasPrev }} disabled{{ end }}">
|
|
||||||
<a {{ if $pag.HasPrev }}href="{{ $pag.Prev.URL }}"{{ end }} class="page-link" aria-label="Previous"><span aria-hidden="true">«</span></a>
|
|
||||||
</li>
|
|
||||||
{{- $ellipsed := false -}}
|
{{- $ellipsed := false -}}
|
||||||
{{- $shouldEllipse := false -}}
|
{{- $shouldEllipse := false -}}
|
||||||
{{- range $pag.Pagers -}}
|
{{- range $pag.Pagers -}}
|
||||||
{{- $right := sub .TotalPages .PageNumber -}}
|
{{- $right := sub .TotalPages .PageNumber -}}
|
||||||
{{- $showNumber := or (le .PageNumber 3) (eq $right 0) -}}
|
{{- $showNumber := or (le .PageNumber 1) (eq $right 0) -}}
|
||||||
{{- $showNumber := or $showNumber (le .TotalPages 5) -}}{{/* Issue #7523 */}}
|
{{- $showNumber := or $showNumber (le .TotalPages 5) -}}{{/* Issue #7523 */}}
|
||||||
{{- $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) -}}
|
{{- $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 3)) (lt .PageNumber (add $pag.PageNumber 3))) -}}
|
||||||
{{- if $showNumber -}}
|
{{- if $showNumber -}}
|
||||||
{{- $ellipsed = false -}}
|
{{- $ellipsed = false -}}
|
||||||
{{- $shouldEllipse = false -}}
|
{{- $shouldEllipse = false -}}
|
||||||
|
@ -24,22 +19,17 @@
|
||||||
{{- $ellipsed = true -}}
|
{{- $ellipsed = true -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- if $showNumber }}
|
{{- if $showNumber }}
|
||||||
<li class="page-item{{ if eq . $pag }} active{{ end }}">
|
<li>
|
||||||
<a class="page-link" href="{{ .URL }}">{{ .PageNumber }}</a>
|
<a class="pagination-link{{ if eq . $pag }} is-current{{ end }}" href="{{ .URL }}" aria-label="Page {{ .PageNumber }}">{{ .PageNumber }}</a>
|
||||||
</li>
|
</li>
|
||||||
{{- else if $shouldEllipse }}
|
{{- else if $shouldEllipse }}
|
||||||
<li class="page-item disabled">
|
<li>
|
||||||
<span aria-hidden="true"> … </span>
|
<span class="pagination-ellipsis">…</span>
|
||||||
</li>
|
</li>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<li class="page-item{{ if not $pag.HasNext }} disabled{{ end }}">
|
|
||||||
<a {{ if $pag.HasNext }}href="{{ $pag.Next.URL }}"{{ end }} class="page-link" aria-label="Next"><span aria-hidden="true">»</span></a>
|
|
||||||
</li>
|
|
||||||
{{- with $pag.Last }}
|
{{- with $pag.Last }}
|
||||||
<li class="page-item">
|
|
||||||
<a href="{{ .URL }}" class="page-link" aria-label="Last"><span aria-hidden="true">»»</span></a>
|
|
||||||
</li>
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</ul>
|
</ul>
|
||||||
|
</nav>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in New Issue