c3re-website/themes/hugo-theme-flat/layouts/partials/pagination.html

31 lines
896 B
HTML
Raw Normal View History

2023-12-13 22:55:13 +01:00
{{ $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>