web-next: paginar /changelogs (10 por página + navegación)
getCommits ahora recibe page/limit y devuelve {commits, totalPages} (del
header X-PageCount de Gitea). La página lee ?page, muestra 10 commits y usa
el componente Pagination (Anterior/1 2 3…/Siguiente).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { setRequestLocale } from 'next-intl/server'
|
||||
import { getCommits } from '@/lib/changelog'
|
||||
import { Pagination } from '@/components/Pagination'
|
||||
|
||||
export const metadata: Metadata = { title: 'Changelogs' }
|
||||
|
||||
@@ -17,10 +18,18 @@ function formatFecha(iso: string): string {
|
||||
})
|
||||
}
|
||||
|
||||
export default async function ChangelogsPage({ params }: { params: Promise<{ locale: string }> }) {
|
||||
export default async function ChangelogsPage({
|
||||
params,
|
||||
searchParams,
|
||||
}: {
|
||||
params: Promise<{ locale: string }>
|
||||
searchParams: Promise<{ page?: string }>
|
||||
}) {
|
||||
const { locale } = await params
|
||||
const sp = await searchParams
|
||||
const page = Math.max(1, Number(sp.page) || 1)
|
||||
setRequestLocale(locale)
|
||||
const commits = await getCommits(50)
|
||||
const { commits, totalPages } = await getCommits(page, 10)
|
||||
|
||||
return (
|
||||
<div className="main-page">
|
||||
@@ -52,9 +61,11 @@ export default async function ChangelogsPage({ params }: { params: Promise<{ loc
|
||||
<br />
|
||||
</div>
|
||||
))}
|
||||
<p className="centered third-brown">
|
||||
<i>* Mostrando los últimos 50 cambios</i>
|
||||
</p>
|
||||
<Pagination
|
||||
page={page}
|
||||
totalPages={totalPages}
|
||||
hrefFor={(p) => (p === 1 ? '/changelogs' : `/changelogs?page=${p}`)}
|
||||
/>
|
||||
<br />
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user