feat: enhance pagination by allowing dynamic page size in article listing

This commit is contained in:
2026-04-11 00:58:26 -03:00
parent e1c6e9d923
commit dbb459a3a5

View File

@@ -5,19 +5,20 @@ import { FileTextIcon } from 'lucide-react';
const PAGE_SIZE = 9; const PAGE_SIZE = 9;
interface HomeProps { type HomeProps = {
searchParams: Promise<{ page?: string }>; searchParams: Promise<{ page?: string; pageSize?: string }>;
} };
const Home = async ({ searchParams }: HomeProps) => { const Home = async ({ searchParams }: HomeProps) => {
const { page: pageParam } = await searchParams; const { page: pageParam, pageSize: pageSizeParam } = await searchParams;
const page = Math.max(1, Number(pageParam) || 1); const page = Math.max(1, Number(pageParam) || 1);
const pageSize = Number(pageSizeParam) || PAGE_SIZE;
const { const {
data: articles, data: articles,
totalPages, totalPages,
total, total,
} = await getArticlesPaginated(page, PAGE_SIZE); } = await getArticlesPaginated(page, pageSize);
return ( return (
<div className='container mx-auto w-full flex-1 px-4 py-12 md:py-16'> <div className='container mx-auto w-full flex-1 px-4 py-12 md:py-16'>