import Image from 'next/image' import type { Metadata } from 'next' import { notFound } from 'next/navigation' import { getPost, getSeoSettings, getSiteSettings } from '@/lib/api' import { formatDate } from '@/lib/utils' import { getMediaUrl, getMediaAlt } from '@/lib/payload-helpers' import { RichTextRenderer } from '@/components/blocks' import { generateBlogPostingSchema, generateBreadcrumbSchema } from '@/lib/structuredData' interface NewsPostPageProps { params: Promise<{ slug: string }> } export async function generateMetadata({ params }: NewsPostPageProps): Promise { const { slug } = await params const [post, seoSettings] = await Promise.all([ getPost(slug), getSeoSettings(), ]) if (!post) return {} const titleSuffix = seoSettings?.metaDefaults?.titleSuffix || '' const titleBase = post.seo?.metaTitle || post.title const title = titleSuffix ? `${titleBase} ${titleSuffix}` : titleBase const description = post.seo?.metaDescription || post.excerpt || seoSettings?.metaDefaults?.defaultDescription const image = getMediaUrl(post.seo?.ogImage) || getMediaUrl(post.featuredImage) || getMediaUrl(seoSettings?.metaDefaults?.defaultOgImage) return { title, description, openGraph: { title, description: description || undefined, images: image ? [{ url: image }] : undefined, type: 'article', }, twitter: { card: 'summary_large_image', title, description: description || undefined, images: image ? [image] : undefined, }, } } export default async function NewsPostPage({ params }: NewsPostPageProps) { const { slug } = await params const [post, settings] = await Promise.all([ getPost(slug), getSiteSettings(), ]) if (!post) { notFound() } const imageUrl = getMediaUrl(post.featuredImage) const blogSchema = generateBlogPostingSchema(post, settings) const breadcrumbSchema = generateBreadcrumbSchema([ { name: 'Startseite', url: '/' }, { name: 'News', url: '/news' }, { name: post.title, url: `/news/${post.slug}` }, ]) return (