diff --git a/packages/ui/src/components/CPagination.svelte b/packages/ui/src/components/CPagination.svelte index ef4d3ae..9c112ef 100644 --- a/packages/ui/src/components/CPagination.svelte +++ b/packages/ui/src/components/CPagination.svelte @@ -84,12 +84,13 @@ } $: boundaryLeft = Math.floor(maxDisplayPages / 2) + $: displayPages = maxDisplayPages < pages ? maxDisplayPages : pages $: pagesArray = Array.from({ - length: maxDisplayPages < pages ? maxDisplayPages : pages, + length: displayPages, }).map((_, i) => { if (current <= boundaryLeft) return i + 1 - if (current >= pages - boundaryLeft) return pages - maxDisplayPages + i + 1 + if (current >= pages - boundaryLeft) return pages - displayPages + i + 1 return i <= boundaryLeft ? current - boundaryLeft + i