small fixes

This commit is contained in:
teldra 2022-04-03 21:31:40 +02:00
parent 76695ce6ca
commit 408cabab0f

View File

@ -1,5 +1,5 @@
{{ $paginator := .paginator}} {{ $paginator := .paginator}}
<div id="pagination"> <div id="pagination">
<!-- Number of links either side of the current page. --> <!-- Number of links either side of the current page. -->
{{ $adjacent_links := 2 }} {{ $adjacent_links := 2 }}
@ -15,74 +15,73 @@
<!-- If there's more than one page. --> <!-- If there's more than one page. -->
{{ if gt $paginator.TotalPages 1 }} {{ if gt $paginator.TotalPages 1 }}
<!-- First page. -->
<!-- First page. --> {{ if ne $paginator.PageNumber 1 }}
{{ if ne $paginator.PageNumber 1 }} <a class="pagination__link pagination__link--first" href="{{ $paginator.First.URL }}">
<a class="pagination__link pagination__link--first" href="{{ $paginator.First.URL }}"> ««
«« </a>
</a> {{ end }}
{{ end }}
<!-- Previous page. --> <!-- Previous page. -->
{{ if $paginator.HasPrev }} {{ if $paginator.HasPrev }}
<a href="{{ $paginator.Prev.URL }}" class="pagination__link pagination__link--previous"> <a href="{{ $paginator.Prev.URL }}" class="pagination__link pagination__link--previous">
« «
</a> </a>
{{ end }} {{ end }}
<!-- Page numbers. -->
{{ range $paginator.Pagers }}
{{ $page_number_flag := false }}
<!-- Page numbers. -->
<!-- Advanced page numbers. --> {{ range $paginator.Pagers }}
{{ if gt $paginator.TotalPages $max_links }} {{ $page_number_flag := false }}
<!-- Lower limit pages. --> <!-- Advanced page numbers. -->
<!-- If the user is on a page which is in the lower limit. --> {{ if gt $paginator.TotalPages $max_links }}
{{ if le $paginator.PageNumber $lower_limit }}
<!-- If the current loop page is less than max_links. --> <!-- Lower limit pages. -->
{{ if le .PageNumber $max_links }} <!-- If the user is on a page which is in the lower limit. -->
{{ $page_number_flag = true }} {{ if le $paginator.PageNumber $lower_limit }}
{{ end }}
<!-- If the current loop page is less than max_links. -->
{{ if le .PageNumber $max_links }}
{{ $page_number_flag = true }}
{{ end }}
<!-- Upper limit pages. -->
<!-- If the user is on a page which is in the upper limit. -->
{{ else if ge $paginator.PageNumber $upper_limit }}
<!-- If the current loop page is greater than total pages minus $max_links -->
{{ if gt .PageNumber (sub $paginator.TotalPages $max_links) }}
{{ $page_number_flag = true }}
{{ end }}
<!-- Middle pages. -->
{{ else }}
{{ if and ( ge .PageNumber (sub $paginator.PageNumber $adjacent_links) ) ( le .PageNumber (add $paginator.PageNumber $adjacent_links) ) }}
{{ $page_number_flag = true }}
{{ end }}
{{ end }}
<!-- Upper limit pages. --> <!-- Simple page numbers. -->
<!-- If the user is on a page which is in the upper limit. --> {{ else }}
{{ else if ge $paginator.PageNumber $upper_limit }}
<!-- If the current loop page is greater than total pages minus $max_links --> {{ $page_number_flag = true }}
{{ if gt .PageNumber (sub $paginator.TotalPages $max_links) }}
{{ $page_number_flag = true }}
{{ end }}
{{ end }}
<!-- Middle pages. --> <!-- Output page numbers. -->
{{ else }} {{ if eq $page_number_flag true }}
<a href="{{ .URL }}" class="pagination__link">
{{ if and ( ge .PageNumber (sub $paginator.PageNumber $adjacent_links) ) ( le .PageNumber (add $paginator.PageNumber $adjacent_links) ) }} {{ if eq $paginator.PageNumber .PageNumber }}<b>{{ end }}
{{ $page_number_flag = true }} {{ .PageNumber }}
{{ end }} {{ if eq $paginator.PageNumber .PageNumber }}</b>{{ end }}
</a>
{{ end }}
{{ end }} {{ end }}
<!-- Simple page numbers. -->
{{ else }}
{{ $page_number_flag = true }}
{{ end }}
<!-- Output page numbers. -->
{{ if eq $page_number_flag true }}
<a href="{{ .URL }}" class="pagination__link">
{{ .PageNumber }}
</a>
{{ end }}
{{ end }}
<!-- Next page. --> <!-- Next page. -->
{{ if $paginator.HasNext }} {{ if $paginator.HasNext }}
@ -97,6 +96,5 @@
»» »»
</a> </a>
{{ end }} {{ end }}
{{ end }} {{ end }}
</div> </div>