{{- $paginator := .paginator -}} {{- $base := .base | default "/" -}} {{- $current := $paginator.PageNumber -}} {{- $total := $paginator.TotalPages -}} {{- if ge $total 2 -}} {{- $split := 2 -}} {{- if lt $total 9 -}}{{- $split = 9 -}} {{- else if lt $current 4 -}}{{- $split = sub 5 $current -}} {{- else if lt (sub $total 4) $current -}}{{- $split = add 5 (sub $current $total) -}} {{- end -}} {{- $from := sub $current $split -}} {{- if lt $from 1 -}}{{- $from = 1 -}}{{- end -}} {{- $to := add $current $split -}} {{- if gt $to $total -}}{{- $to = $total -}}{{- end -}}
    {{- if gt $current 1 -}} {{- $u := partial "page-url.html" (dict "page" (sub $current 1) "base" $base) -}}
  1. {{- end -}} {{- if gt $from 1 -}} {{- $u := partial "page-url.html" (dict "page" 1 "base" $base) -}}
  2. 1
  3. {{- if gt $from 2 -}}{{- end -}} {{- end -}} {{- range $i := seq $from $to -}} {{- if eq $i $current -}}
  4. {{ $i }}
  5. {{- else -}} {{- $u := partial "page-url.html" (dict "page" $i "base" $base) -}}
  6. {{ $i }}
  7. {{- end -}} {{- end -}} {{- if lt $to $total -}} {{- if lt $to (sub $total 1) -}}{{- end -}} {{- $u := partial "page-url.html" (dict "page" $total "base" $base) -}}
  8. {{ $total }}
  9. {{- end -}} {{- if lt $current $total -}} {{- $u := partial "page-url.html" (dict "page" (add $current 1) "base" $base) -}}
  10. {{- end -}}
{{- end -}}