import { motion } from "framer-motion"; interface Props { page: number; // 1-based pageCount: number; onPage: (page: number) => void; } /** Build a windowed page list with ellipses, e.g. 1 … 4 5 6 … 12 */ function pageItems(page: number, count: number): (number | "…")[] { if (count <= 7) return Array.from({ length: count }, (_, i) => i + 1); const items: (number | "…")[] = [1]; const start = Math.max(2, page - 1); const end = Math.min(count - 1, page + 1); if (start > 2) items.push("…"); for (let i = start; i <= end; i++) items.push(i); if (end < count - 1) items.push("…"); items.push(count); return items; } export function Pagination({ page, pageCount, onPage }: Props) { if (pageCount <= 1) return null; const items = pageItems(page, pageCount); return (
{items.map((it, i) => it === "…" ? ( ) : ( ), )}
); }