{featuredPost.frontmatter.excerpt}
> )}import Link from 'next/link'; import Image from 'next/image'; import { getAllPosts } from '@/lib/blog'; import { Section, Container, Heading, Card, Badge, Button } from '@/components/ui'; import Reveal from '@/components/Reveal'; import { Metadata } from 'next'; import { getTranslations, setRequestLocale } from 'next-intl/server'; import { SITE_URL } from '@/lib/schema'; import { BlogPaginationKeyboardObserver } from '@/components/blog/BlogPaginationKeyboardObserver'; interface BlogIndexProps { params: Promise<{ locale: string; }>; } export async function generateMetadata({ params }: BlogIndexProps) { const { locale } = await params; const t = await getTranslations({ locale, namespace: 'Blog.meta' }); return { title: t('title'), description: t('description'), alternates: { canonical: `${SITE_URL}/${locale}/blog`, languages: { de: `${SITE_URL}/de/blog`, en: `${SITE_URL}/en/blog`, 'x-default': `${SITE_URL}/en/blog`, }, }, openGraph: { title: `${t('title')} | KLZ Cables`, description: t('description'), url: `${SITE_URL}/${locale}/blog`, }, twitter: { card: 'summary_large_image', title: `${t('title')} | KLZ Cables`, description: t('description'), }, }; } export default async function BlogIndex({ params }: BlogIndexProps) { const { locale } = await params; setRequestLocale(locale); const t = await getTranslations('Blog'); 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 (
{featuredPost.frontmatter.excerpt}
> )}{post.frontmatter.excerpt}