Want to contribute? Fork me on Codeberg.org!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
3.2 KiB

{{ $pag := . }}
{{ $scratch := newScratch }}
{{ if gt $pag.TotalPages 1 }}
{{ $scratch.Set "dot_rendered" false }}
<nav aria-label="page navigation">
{{ if and (ne $pag.PageNumber 1) }}
<a href="{{ $pag.First.URL }}" rel="first"
{{- else -}}
<span class="disabled"
{{- end }} title="First page">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M18.75 19.5l-7.5-7.5 7.5-7.5m-6 15L5.25 12l7.5-7.5" />
</svg>
{{ if and (ne $pag.PageNumber 1) }}
</a>
{{ else }}
</span>
{{ end }}
{{ if $pag.HasPrev }}
<a href="{{ $pag.Prev.URL }}" rel="prev"
{{- else -}}
<span class="disabled"
{{- end }} title="Previous page">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5L8.25 12l7.5-7.5" />
</svg>
{{ if $pag.HasPrev }}
</a>
{{ else }}
</span>
{{ end }}
{{ range $pag.Pagers }}
{{ if eq . $pag }}
<span>{{ .PageNumber }}</span>
{{ else if and (ge .PageNumber (sub $pag.PageNumber 2)) (le .PageNumber (add $pag.PageNumber 2)) }}
{{ $scratch.Set "dot_rendered" false }}
<a href="{{ .URL }}">{{ .PageNumber }}</a>
{{ else if eq ($scratch.Get "dot_rendered") false }}
{{ $scratch.Set "dot_rendered" true }}
<span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
</svg>
</span>
{{ end }}
{{ end }}
{{ if $pag.HasNext }}
<a href="{{ $pag.Next.URL }}" rel="next"
{{- else -}}
<span class="disabled"
{{- end }} title="Next page">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
</svg>
{{ if $pag.HasNext }}
</a>
{{ else }}
</span>
{{ end }}
{{ if and (ne $pag.PageNumber $pag.TotalPages) }}
<a href="{{ $pag.Last.URL }}" rel="last"
{{- else -}}
<span class="disabled"
{{ end }} title="Last page">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M11.25 4.5l7.5 7.5-7.5 7.5m-6-15l7.5 7.5-7.5 7.5" />
</svg>
{{ if and (ne $pag.PageNumber $pag.TotalPages) }}
</a>
{{ else }}
</span>
{{ end }}
</nav>
{{ end }}