mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
e3e627e6b7
commit
4b560cc119
1 changed files with 38 additions and 34 deletions
|
@ -1,40 +1,44 @@
|
||||||
{{ $pag := $.Paginator }}
|
{{ $pag := $.Paginator }}
|
||||||
{{ if gt $pag.TotalPages 1 }}
|
{{ if gt $pag.TotalPages 1 -}}
|
||||||
<ul class="pagination">
|
<ul class="pagination">
|
||||||
{{ with $pag.First }}
|
{{ with $pag.First -}}
|
||||||
<li class="page-item">
|
<li class="page-item">
|
||||||
<a href="{{ .URL }}" class="page-link" aria-label="First"><span aria-hidden="true">««</span></a>
|
<a href="{{ .URL }}" class="page-link" aria-label="First"><span aria-hidden="true">««</span></a>
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end -}}
|
||||||
<li class="page-item{{ if not $pag.HasPrev }} disabled{{ 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>
|
<a {{ if $pag.HasPrev }}href="{{ $pag.Prev.URL }}"{{ end }} class="page-link" aria-label="Previous"><span aria-hidden="true">«</span></a>
|
||||||
</li>
|
</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 3) (eq $right 0) -}}
|
||||||
{{ $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 2)) (lt .PageNumber (add $pag.PageNumber 2))) -}}
|
||||||
{{ if $showNumber }}
|
{{- if $showNumber -}}
|
||||||
{{ $ellipsed = false }}
|
{{- $ellipsed = false -}}
|
||||||
{{ $shouldEllipse = false }}
|
{{- $shouldEllipse = false -}}
|
||||||
{{ else }}
|
{{- else -}}
|
||||||
{{ $shouldEllipse = not $ellipsed }}
|
{{- $shouldEllipse = not $ellipsed -}}
|
||||||
{{ $ellipsed = true }}
|
{{- $ellipsed = true -}}
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
{{ if $showNumber }}
|
{{- if $showNumber }}
|
||||||
<li class="page-item{{ if eq . $pag }} active{{ end }}"><a class="page-link" href="{{ .URL }}">{{ .PageNumber }}</a></li>
|
<li class="page-item{{ if eq . $pag }} active{{ end }}">
|
||||||
{{ else if $shouldEllipse }}
|
<a class="page-link" href="{{ .URL }}">{{ .PageNumber }}</a>
|
||||||
<li class="page-item disabled"><span aria-hidden="true"> … </span></li>
|
</li>
|
||||||
{{ end }}
|
{{- else if $shouldEllipse }}
|
||||||
{{ end }}
|
<li class="page-item disabled">
|
||||||
<li class="page-item{{ if not $pag.HasNext }} disabled{{ end }}">
|
<span aria-hidden="true"> … </span>
|
||||||
|
</li>
|
||||||
|
{{- 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>
|
<a {{ if $pag.HasNext }}href="{{ $pag.Next.URL }}"{{ end }} class="page-link" aria-label="Next"><span aria-hidden="true">»</span></a>
|
||||||
</li>
|
</li>
|
||||||
{{ with $pag.Last }}
|
{{- with $pag.Last }}
|
||||||
<li class="page-item">
|
<li class="page-item">
|
||||||
<a href="{{ .URL }}" class="page-link" aria-label="Last"><span aria-hidden="true">»»</span></a>
|
<a href="{{ .URL }}" class="page-link" aria-label="Last"><span aria-hidden="true">»»</span></a>
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{- end }}
|
||||||
</ul>
|
</ul>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in a new issue