mirror of
https://github.com/adulau/sillon-fictionnel.git
synced 2024-11-21 17:47:05 +00:00
chg: [layout] Voici la fin
This commit is contained in:
parent
5cb1772d6d
commit
2f078fb56d
3 changed files with 89 additions and 2 deletions
|
@ -9,7 +9,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
{{ template "_internal/pagination.html" . }}
|
||||
{{ partial "shared/pagination.html" . }}
|
||||
</div>
|
||||
</main>
|
||||
{{ end }}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
{{ template "_internal/pagination.html" . }}
|
||||
{{ partial "shared/pagination.html" . }}
|
||||
</div>
|
||||
</main>
|
||||
{{ end }}
|
||||
|
|
87
themes/writeonly/layouts/partials/shared/pagination.html
Normal file
87
themes/writeonly/layouts/partials/shared/pagination.html
Normal file
|
@ -0,0 +1,87 @@
|
|||
{{ $paginator := $.Paginator }}
|
||||
<!-- Number of links either side of the current page. -->
|
||||
{{ $adjacent_links := 2 }}
|
||||
<!-- $max_links = ($adjacent_links * 2) + 1 -->
|
||||
{{ $max_links := (add (mul $adjacent_links 2) 1) }}
|
||||
<!-- $lower_limit = $adjacent_links + 1 -->
|
||||
{{ $lower_limit := (add $adjacent_links 1) }}
|
||||
<!-- $upper_limit = $paginator.TotalPages - $adjacent_links -->
|
||||
{{ $upper_limit := (sub $paginator.TotalPages $adjacent_links) }}
|
||||
|
||||
{{ if gt $paginator.TotalPages 1 }}
|
||||
<nav aria-label="Page navigation" class="w-100">
|
||||
<ul class="pagination justify-content-center pagination-lg">
|
||||
<!-- First page. -->
|
||||
{{ if ne $paginator.PageNumber 1 }}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{{ $paginator.First.URL }}">
|
||||
Début
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
<!-- Previous page. -->
|
||||
{{ if $paginator.HasPrev }}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{{ $paginator.Prev.URL }}" rel="next">
|
||||
←
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
<!-- Page numbers. -->
|
||||
{{ range $paginator.Pagers }}
|
||||
{{ $.Scratch.Set "page_number_flag" false }}
|
||||
<!-- Advanced page numbers. -->
|
||||
{{ if gt $paginator.TotalPages $max_links }}
|
||||
<!-- Lower limit pages. -->
|
||||
<!-- If the user is on a page which is in the lower limit. -->
|
||||
{{ if le $paginator.PageNumber $lower_limit }}
|
||||
<!-- If the current loop page is less than max_links. -->
|
||||
{{ if le .PageNumber $max_links }}
|
||||
{{ $.Scratch.Set "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) }}
|
||||
{{ $.Scratch.Set "page_number_flag" true }}
|
||||
{{ end }}
|
||||
<!-- Middle pages. -->
|
||||
{{ else }}
|
||||
{{ if and ( ge .PageNumber (sub $paginator.PageNumber $adjacent_links) ) ( le .PageNumber (add $paginator.PageNumber $adjacent_links) ) }}
|
||||
{{ $.Scratch.Set "page_number_flag" true }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<!-- Simple page numbers. -->
|
||||
{{ else }}
|
||||
{{ $.Scratch.Set "page_number_flag" true }}
|
||||
{{ end }}
|
||||
<!-- Output page numbers. -->
|
||||
{{ if eq ($.Scratch.Get "page_number_flag") true }}
|
||||
<li class="page-item{{ if eq . $paginator }} active{{ end }}">
|
||||
<a class="page-link" href="{{ .URL }}" >
|
||||
{{ .PageNumber }}
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
<!-- Next page. -->
|
||||
{{ if $paginator.HasNext }}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{{ $paginator.Next.URL }}" >
|
||||
→
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
<!-- Last page. -->
|
||||
{{ if ne $paginator.PageNumber $paginator.TotalPages }}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{{ $paginator.Last.URL }}">
|
||||
Fin
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
<!-- </nav> -->
|
||||
</nav>
|
||||
{{ end }}
|
Loading…
Reference in a new issue