{{ $pag := $.Paginator }}
{{ if gt $pag.TotalPages 1 }}
<nav class="pagination w-full flex justify-center py-10">
<ul class="flex w-max items-center space-x-2">
    {{ with $pag.First }}
        <li>
            <a href="{{ .URL }}" class="pagination-link text-salmon" disabled aria-label="First">
                <span aria-hidden="true">
                    <svg xmlns="http://www.w3.org/2000/svg" width="17" height="18"><g fill="none" fill-rule="evenodd" stroke="#FA765B" stroke-width="2"><path d="M16 17 8 9l8-8"/><path d="M10 17 2 9l8-8"/></g></svg>
                </span>
            </a>
        </li>
    {{ end }}
    <li>
        <a href="{{ if $pag.HasPrev }}{{ $pag.Prev.URL }}{{ end }}" class="pagination-link" {{ if not $pag.HasPrev }} disabled{{ end }} aria-label="Previous"><svg xmlns="http://www.w3.org/2000/svg" width="17" height="18"><g fill="none" fill-rule="evenodd" stroke="#FA765B" stroke-width="2"><path d="M10 17 2 9l8-8"/></g></svg></a>
    </li>
    {{ $ellipsed := false }}
    {{ $shouldEllipse := false }}
    {{ 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 }}
        {{ $ellipsed = false }}
        {{ $shouldEllipse = false }}
    {{ else }}
        {{ $shouldEllipse = not $ellipsed }}
        {{ $ellipsed = true }}
    {{ end }}
    {{ if $showNumber }}
    <li><a class="pagination-link text-xl leading-normal {{ if eq . $pag }}text-salmon underline{{ end }}" href="{{ .URL }}">{{ .PageNumber }}</a></li>
    {{ else if $shouldEllipse }}
    <li class="pagination-link" disabled><span aria-hidden="true">&nbsp;&hellip;&nbsp;</span></li>
    {{ end }}
    {{ end }}
    <li>
    <a href="{{ if $pag.HasNext }}{{ $pag.Next.URL }}{{ end }}" class="pagination-link" {{ if not $pag.HasNext }}disabled{{ end }} aria-label="Next"><svg xmlns="http://www.w3.org/2000/svg" width="11" height="18" fill="none"><path stroke="#FA765B" stroke-width="2" d="m1 1 8 8-8 8"/></svg></a>
    </li>
    {{ with $pag.Last }}
    <li>
        <a class="flex" href="{{ .URL }}" class="pagination-link" {{ if not $pag.HasNext }}disabled{{ end }} aria-label="Last">
            <svg xmlns="http://www.w3.org/2000/svg" width="17" height="18"><g fill="none" fill-rule="evenodd" stroke="#FA765B" stroke-width="2"><path d="m1 1 8 8-8 8"/><path d="m7 1 8 8-8 8"/></g></svg>
        </a>
    </li>
    {{ end }}
</ul>
</nav>
{{ end }}