120 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			120 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!--
 | ||
| //
 | ||
| //  PAGE NUMBERS
 | ||
| //––––––––––––––––––––––––––––––––––––––––––––––––––
 | ||
| -->
 | ||
| {{ $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 there's more than one page. -->
 | ||
| {{ if gt $paginator.TotalPages 1 }}
 | ||
| 
 | ||
|   <ul class="pagination">
 | ||
|     
 | ||
|     <!-- First page. -->
 | ||
|     {{ if ne $paginator.PageNumber 1 }}
 | ||
|     <li class="pagination__item pagination__item--first">
 | ||
|       <a class="pagination__link pagination__link--first" href="{{ $paginator.First.URL }}">
 | ||
|         First
 | ||
|       </a>
 | ||
|     </li>
 | ||
|     {{ end }}
 | ||
| 
 | ||
|     <!-- Previous page. -->
 | ||
|     {{ if $paginator.HasPrev }}
 | ||
|     <li class="pagination__item pagination__item--previous">
 | ||
|       <a href="{{ $paginator.Prev.URL }}" class="pagination__link pagination__link--previous">
 | ||
|         <svg  xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 24 24"  fill="none"  stroke="currentColor"  stroke-width="2"  stroke-linecap="round"  stroke-linejoin="round"  class="icon icon-tabler icons-tabler-outline icon-tabler-arrow-left"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l14 0" /><path d="M5 12l6 6" /><path d="M5 12l6 -6" /></svg>
 | ||
|       </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="pagination__item{{ if eq . $paginator }} pagination__item--current{{ end }}">
 | ||
|           <a href="{{ .URL }}" class="pagination__link">
 | ||
|             {{ .PageNumber }}
 | ||
|           </a>
 | ||
|         </li>
 | ||
|       {{ end }}
 | ||
| 
 | ||
|     {{ end }}
 | ||
| 
 | ||
|     <!-- Next page. -->
 | ||
|     {{ if $paginator.HasNext }}
 | ||
|     <li class="pagination__item pagination__item--next">
 | ||
|       <a href="{{ $paginator.Next.URL }}" class="pagination__link pagination__link--next">
 | ||
|         <svg  xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 24 24"  fill="none"  stroke="currentColor"  stroke-width="2"  stroke-linecap="round"  stroke-linejoin="round"  class="icon icon-tabler icons-tabler-outline icon-tabler-arrow-right"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l14 0" /><path d="M13 18l6 -6" /><path d="M13 6l6 6" /></svg>
 | ||
|       </a>
 | ||
|     </li>
 | ||
|     {{ end }}
 | ||
| 
 | ||
|     <!-- Last page. -->
 | ||
|     {{ if ne $paginator.PageNumber $paginator.TotalPages }}
 | ||
|     <li class="pagination__item pagination__item--last">
 | ||
|       <a class="pagination__link pagination__link--last" href="{{ $paginator.Last.URL }}">
 | ||
|         Last
 | ||
|       </a>
 | ||
|     </li>
 | ||
|     {{ end }}
 | ||
| 
 | ||
|   </ul><!-- .pagination -->
 | ||
| {{ end }} |