import Link from 'next/link'; import { getAllPosts } from '@/lib/blog'; import { getTranslations } from 'next-intl/server'; interface BlogIndexProps { params: { locale: string; }; } export async function generateMetadata({ params: { locale } }: BlogIndexProps) { return { title: locale === 'de' ? 'Neuigkeiten zu Kabeln und Energielösungen' : 'News on Cables and Energy Solutions', description: locale === 'de' ? 'Bleiben Sie auf dem Laufenden! Lesen Sie aktuelle Themen und Insights zu Kabeltechnologie, Energielösungen und branchenspezifischen Innovationen.' : 'Stay up to date! Read current topics and insights on cable technology, energy solutions and industry-specific innovations.', }; } export default async function BlogIndex({ params: { locale } }: BlogIndexProps) { const posts = await getAllPosts(locale); // Sort posts by date descending const sortedPosts = [...posts].sort((a, b) => new Date(b.frontmatter.date).getTime() - new Date(a.frontmatter.date).getTime() ); const featuredPost = sortedPosts[0]; const remainingPosts = sortedPosts.slice(1); return (
{/* Hero Section */}

{locale === 'de' ? 'KLZ Blog' : 'KLZ Blog'}

{locale === 'de' ? 'Insights, News und technisches Know-how aus der Welt der Kabelinfrastruktur und erneuerbaren Energien.' : 'Insights, news and technical know-how from the world of cable infrastructure and renewable energies.'}

{/* Featured Post */} {featuredPost && (
{featuredPost.frontmatter.featuredImage && (
{featuredPost.frontmatter.title}
)}
{featuredPost.frontmatter.category && ( {featuredPost.frontmatter.category} )}

{featuredPost.frontmatter.title}

{featuredPost.frontmatter.excerpt}

KLZ
KLZ Cables
{new Date(featuredPost.frontmatter.date).toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric' })}
)} {/* Grid for remaining posts */}
{remainingPosts.map((post) => (
{post.frontmatter.featuredImage && (
{post.frontmatter.title} {post.frontmatter.category && ( {post.frontmatter.category} )}
)}
{new Date(post.frontmatter.date).toLocaleDateString(locale, { year: 'numeric', month: 'long', day: 'numeric' })}

{post.frontmatter.title}

{post.frontmatter.excerpt}

{locale === 'de' ? 'Weiterlesen' : 'Read more'}
))}
); }