Monorepo for Tangled tangled.org
11

Configure Feed

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

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