mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-05 19:51:02 +00:00
parent
6e2f2dd8d3
commit
b6ea492b7a
1 changed files with 41 additions and 26 deletions
|
@ -134,9 +134,24 @@ func (t *templateHandler) embedTemplates() {
|
||||||
{{ if not $pag.HasPrev }}class="disabled"{{ end }}>
|
{{ if not $pag.HasPrev }}class="disabled"{{ end }}>
|
||||||
<a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" aria-label="Previous"><span aria-hidden="true">«</span></a>
|
<a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" aria-label="Previous"><span aria-hidden="true">«</span></a>
|
||||||
</li>
|
</li>
|
||||||
|
{{ $.Scratch.Set "__paginator.ellipsed" false }}
|
||||||
{{ range $pag.Pagers }}
|
{{ range $pag.Pagers }}
|
||||||
|
{{ $right := sub .TotalPages .PageNumber }}
|
||||||
|
{{ $showNumber := or (le .PageNumber 3) (eq $right 0) }}
|
||||||
|
{{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 2)) (lt .PageNumber (add $pag.PageNumber 2))) }}
|
||||||
|
{{ if $showNumber }}
|
||||||
|
{{ $.Scratch.Set "__paginator.ellipsed" false }}
|
||||||
|
{{ $.Scratch.Set "__paginator.shouldEllipse" false }}
|
||||||
|
{{ else }}
|
||||||
|
{{ $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }}
|
||||||
|
{{ $.Scratch.Set "__paginator.ellipsed" true }}
|
||||||
|
{{ end }}
|
||||||
|
{{ if $showNumber }}
|
||||||
<li
|
<li
|
||||||
{{ if eq . $pag }}class="active"{{ end }}><a href="{{ .URL }}">{{ .PageNumber }}</a></li>
|
{{ if eq . $pag }}class="active"{{ end }}><a href="{{ .URL }}">{{ .PageNumber }}</a></li>
|
||||||
|
{{ else if ($.Scratch.Get "__paginator.shouldEllipse") }}
|
||||||
|
<li class="disabled"><span aria-hidden="true">…</span></li>
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<li
|
<li
|
||||||
{{ if not $pag.HasNext }}class="disabled"{{ end }}>
|
{{ if not $pag.HasNext }}class="disabled"{{ end }}>
|
||||||
|
|
Loading…
Reference in a new issue