hugo-theme-flat/layouts/partials/pagination.html
2022-04-27 21:54:00 +08:00

31 lines
896 B
HTML

{{ $pag := $.Paginator }}
<nav class="pagination">
{{ $size := 2 }}
{{ $current := $pag.PageNumber}}
{{ $total := $pag.TotalPages}}
{{ $prev := 0 }}
{{ range $pag.Pagers }}
{{ if or ( and ( ge .PageNumber (sub $current $size) )
( le .PageNumber (add $current $size) )
)
(or (eq .PageNumber 1)
(eq .PageNumber $total)
)
}}
{{ if not (eq .PageNumber (add $prev 1) ) }}
<span>··</span>
{{ end }}
{{ $prev = .PageNumber }}
{{ if eq .PageNumber $current }}
<a class="enabled current" href="{{ .URL }}">{{ .PageNumber }}</a>
{{ else }}
<a class="enabled" href="{{ .URL }}">{{ .PageNumber }}</a>
{{ end }}
{{ end }}
{{ end }}
</nav>