This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / appview / pages / templates / fragments / pagination.html
3.0 kB 94 lines
1{{ define "fragments/pagination" }} 2 {{/* Params: Page (pagination.Page), BasePath (string), QueryParams (url.Values), TotalCount (int)|HasMore (bool) */}} 3 {{/* Cursor mode when HasMore is provided */}} 4 5 {{ $page := .Page }} 6 {{ $totalCount := .TotalCount }} 7 {{ $basePath := .BasePath }} 8 {{ $queryParams := safeUrl .QueryParams.Encode }} 9 {{ $cursor := mapContains . "HasMore" }} 10 11 {{ $prev := $page.Previous.Offset }} 12 {{ $next := $page.Next.Offset }} 13 14 {{ $hasNext := false }} 15 {{ if $cursor }} 16 {{ $hasNext = .HasMore }} 17 {{ else }} 18 {{ $hasNext = lt $next $totalCount }} 19 {{ end }} 20 21 <div class="flex justify-center items-center mt-4 gap-5"> 22 <a 23 class=" 24 flex items-center gap-1 no-underline hover:no-underline dark:text-white text-sm 25 {{ if le $page.Offset 0 }} 26 cursor-not-allowed opacity-50 27 {{ end }} 28 " 29 {{ if gt $page.Offset 0 }} 30 hx-boost="true" 31 href="{{ $basePath }}?{{ $queryParams }}&offset={{ $prev }}&limit={{ $page.Limit }}" 32 {{ end }} 33 > 34 {{ i "chevron-left" "w-4 h-4" }} 35 Prev 36 </a> 37 38 {{ if not $cursor }} 39 {{ $lastPage := sub $totalCount (mod $totalCount $page.Limit) }} 40 41 {{ if gt $page.Offset 0 }} 42 <a hx-boost="true" href="{{ $basePath }}?{{ $queryParams }}&offset=0&limit={{ $page.Limit }}"> 43 1 44 </a> 45 {{ end }} 46 47 {{ if gt $prev $page.Limit }} 48 <span class="text-gray-400 dark:text-gray-500"></span> 49 {{ end }} 50 51 {{ if gt $prev 0 }} 52 <a hx-boost="true" href="{{ $basePath }}?{{ $queryParams }}&offset={{ $prev }}&limit={{ $page.Limit }}"> 53 {{ add (div $prev $page.Limit) 1 }} 54 </a> 55 {{ end }} 56 57 <span class="px-2 py-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-sm"> 58 {{ add (div $page.Offset $page.Limit) 1 }} 59 </span> 60 61 {{ if lt $next $lastPage }} 62 <a hx-boost="true" href="{{ $basePath }}?{{ $queryParams }}&offset={{ $next }}&limit={{ $page.Limit }}"> 63 {{ add (div $next $page.Limit) 1 }} 64 </a> 65 {{ end }} 66 67 {{ if lt $next (sub $totalCount (mul 2 $page.Limit)) }} 68 <span class="text-gray-400 dark:text-gray-500"></span> 69 {{ end }} 70 71 {{ if lt $page.Offset $lastPage }} 72 <a hx-boost="true" href="{{ $basePath }}?{{ $queryParams }}&offset={{ $lastPage }}&limit={{ $page.Limit }}"> 73 {{ add (div $lastPage $page.Limit) 1 }} 74 </a> 75 {{ end }} 76 {{ end }} 77 78 <a 79 class=" 80 flex items-center gap-1 no-underline hover:no-underline dark:text-white text-sm 81 {{ if not $hasNext }} 82 cursor-not-allowed opacity-50 83 {{ end }} 84 " 85 {{ if $hasNext }} 86 hx-boost="true" 87 href="{{ $basePath }}?{{ $queryParams }}&offset={{ $next }}&limit={{ $page.Limit }}" 88 {{ end }} 89 > 90 Next 91 {{ i "chevron-right" "w-4 h-4" }} 92 </a> 93 </div> 94{{ end }}