import type { Metadata } from 'next/types' import configPromise from '@payload-config' import { getPayload } from 'payload' import React from 'react' 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() { const payload = await getPayload({ config: configPromise }) const posts = await payload.find({ collection: 'posts', depth: 1, limit: 12, overrideAccess: false, select: { title: true, slug: true, heroImage: true, meta: true, publishedAt: true, }, }) return (

Nyheter!

{posts.docs.length === 0 ? (

Inga inlägg hittades.

) : (
{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 && (
)}
) } export function generateMetadata(): Metadata { return { title: 'Nyheter | Fiber Direkt', description: 'Senaste nytt från Fiber Direkt', } }