diff --git a/src/components/sections/News.tsx b/src/components/sections/News.tsx index e6ce631..7f004e8 100644 --- a/src/components/sections/News.tsx +++ b/src/components/sections/News.tsx @@ -121,11 +121,11 @@ function CompactArticle({ ); } -const INITIAL_VISIBLE = 4; +const PER_PAGE = 4; export function News({ data }: NewsProps) { const [selected, setSelected] = useState(null); - const [showAll, setShowAll] = useState(false); + const [page, setPage] = useState(0); if (!data.items || data.items.length === 0) return null; @@ -135,8 +135,8 @@ export function News({ data }: NewsProps) { .sort((a, b) => (b.date || "").localeCompare(a.date || "")); if (sorted.length === 0) return null; const [featured, ...rest] = sorted; - const visibleRest = showAll ? rest : rest.slice(0, INITIAL_VISIBLE - 1); - const hasMore = rest.length > INITIAL_VISIBLE - 1 && !showAll; + const totalPages = Math.max(1, Math.ceil(rest.length / PER_PAGE)); + const visibleRest = rest.slice(page * PER_PAGE, (page + 1) * PER_PAGE); return (
@@ -168,17 +168,48 @@ export function News({ data }: NewsProps) { )} - {hasMore && ( - -
+ {totalPages > 1 && ( +
+ + {Array.from({ length: totalPages }, (_, i) => ( -
- + ))} + +
)}