import { Metadata } from 'next'; import Link from 'next/link'; import { getPostsByLocale, getCategoriesByLocale, getMediaById } from '@/lib/data'; import { getSiteInfo, t, getLocalizedPath } from '@/lib/i18n'; import { SEO } from '@/components/SEO'; import { LocaleSwitcher } from '@/components/LocaleSwitcher'; import { ContentRenderer } from '@/components/content/ContentRenderer'; interface PageProps { params: { locale?: string; }; } export async function generateStaticParams() { return [ { locale: 'en' }, { locale: 'de' }, ]; } export async function generateMetadata({ params }: PageProps): Promise { const locale = (params?.locale as string) || 'en'; const site = getSiteInfo(); const title = t('blog.title', locale as 'en' | 'de'); const description = t('blog.description', locale as 'en' | 'de'); return { title: `${title} | ${site.title}`, description, alternates: { canonical: getLocalizedPath('/blog', locale as 'en' | 'de'), languages: { 'en': '/en/blog', 'de': '/de/blog', }, }, openGraph: { title: `${title} | ${site.title}`, description, type: 'website', locale, }, }; } export default async function BlogPage({ params }: PageProps) { const locale = (params?.locale as string) || 'en'; const posts = getPostsByLocale(locale as 'en' | 'de'); const categories = getCategoriesByLocale(locale as 'en' | 'de'); const title = t('blog.title', locale as 'en' | 'de'); const description = t('blog.description', locale as 'en' | 'de'); // Get featured posts (first 3) const featuredPosts = posts.slice(0, 3); // Get remaining posts const remainingPosts = posts.slice(3); return ( <>

{title}

{description}

{/* Categories */} {categories.length > 0 && (

{t('blog.categories', locale as 'en' | 'de')}

{categories.map((category) => ( {category.name} ))}
)} {/* Featured Posts */} {featuredPosts.length > 0 && (

{t('blog.featured', locale as 'en' | 'de')}

{featuredPosts.map((post) => (
{post.featuredImage && (() => { const media = getMediaById(post.featuredImage); return media ? (
{post.title}
) : null; })()}

{post.title}

{t('blog.readMore', locale as 'en' | 'de')}
))}
)} {/* All Posts */} {remainingPosts.length > 0 && (

{t('blog.allPosts', locale as 'en' | 'de')}

{remainingPosts.map((post) => (
{post.featuredImage && (() => { const media = getMediaById(post.featuredImage); return media ? (
{post.title}
) : null; })()}

{post.title}

{t('blog.readMore', locale as 'en' | 'de')}
))}
)} {/* Empty State */} {posts.length === 0 && (

{t('blog.noPosts', locale as 'en' | 'de')}

{t('blog.noPostsDescription', locale as 'en' | 'de')}

)}
{/* Locale Switcher */}
); }