diff --git a/src/app/(frontend)/posts/page/page.tsx b/src/app/(frontend)/posts/page/page.tsx index 8c8cc1b..e02fe14 100644 --- a/src/app/(frontend)/posts/page/page.tsx +++ b/src/app/(frontend)/posts/page/page.tsx @@ -6,106 +6,70 @@ import type { Post, Media } from '@/payload-types' import { FDImage } from '@/components/FDImage' import { formatDateTime } from '@/utilities/formatDateTime' import { Pagination } from '@/components/Pagination' -import PageClient from './page.client' export const dynamic = 'force-dynamic' -export default async function Page() { +export default async function Page({ params }: { params: Promise<{ pageNumber: string }> }) { + const { pageNumber } = await params const payload = await getPayload({ config: configPromise }) const posts = await payload.find({ collection: 'posts', depth: 1, limit: 12, + page: parseInt(pageNumber, 10), overrideAccess: false, select: { title: true, slug: true, heroImage: true, - categories: true, meta: true, publishedAt: true, - populatedAuthors: true, }, }) return (
- - - {/* ── Page header ── */} -
-

- Nyheter +
+

+ Nyheter!

-

- {posts.totalDocs} {posts.totalDocs === 1 ? 'artikel' : 'artiklar'} -

-
- - {/* ── Card grid ── */} -
- {posts.docs.length === 0 ? ( -

Inga inlägg hittades.

- ) : ( -
- {posts.docs.map((post) => { - const p = post as Post - const heroImage = p.heroImage as Media | undefined - const summary = p.meta?.description ?? null - - return ( - - {/* Image */} -
- {heroImage?.url ? ( - - ) : ( -
- Ingen bild -
- )} -
- - {/* Content */} -
-

- {p.title} -

- - {summary && ( -

- {summary} -

- )} - - {/* Date */} - {p.publishedAt && ( -

- {formatDateTime(p.publishedAt)} -

- )} -
-
- ) - })} -
- )} - - {/* Pagination */} +
+ {posts.docs.map((post) => { + const p = post as Post + const heroImage = p.heroImage as Media | undefined + return ( + +

+ {p.title} +

+ {p.publishedAt && ( +

+ {formatDateTime(p.publishedAt)} +

+ )} +
+ {heroImage?.url ? ( + + ) : ( +
+ Ingen bild +
+ )} +
+
+ ) + })} +
{posts.totalPages > 1 && posts.page && ( -
+
)} @@ -117,6 +81,5 @@ export default async function Page() { export function generateMetadata(): Metadata { return { title: 'Nyheter | Fiber Direkt', - description: 'Senaste nytt från Fiber Direkt', } }