import { notFound } from 'next/navigation'; import JsonLd from '@/components/JsonLd'; import { SITE_URL } from '@/lib/schema'; import { getPostBySlug, getAdjacentPosts, getReadingTime } from '@/lib/blog'; import { Metadata } from 'next'; import Link from 'next/link'; import Image from 'next/image'; import PostNavigation from '@/components/blog/PostNavigation'; import PowerCTA from '@/components/blog/PowerCTA'; import { Heading } from '@/components/ui'; import { setRequestLocale } from 'next-intl/server'; import BlogEngagementTracker from '@/components/analytics/BlogEngagementTracker'; // Payload CMS Imports import PayloadRichText from '@/components/PayloadRichText'; interface BlogPostProps { params: Promise<{ locale: string; slug: string; }>; } export async function generateMetadata({ params }: BlogPostProps): Promise { const { locale, slug } = await params; const post = await getPostBySlug(slug, locale); if (!post) return {}; const description = post.frontmatter.excerpt || ''; return { title: post.frontmatter.title, description: description, alternates: { canonical: `${SITE_URL}/${locale}/blog/${slug}`, }, openGraph: { title: `${post.frontmatter.title} | KLZ Cables`, description: description, type: 'article', publishedTime: post.frontmatter.date, authors: ['KLZ Cables'], url: `${SITE_URL}/${locale}/blog/${slug}`, }, twitter: { card: 'summary_large_image', title: `${post.frontmatter.title} | KLZ Cables`, description: description, }, }; } export default async function BlogPost({ params }: BlogPostProps) { const { locale, slug } = await params; setRequestLocale(locale); const post = await getPostBySlug(slug, locale); const { prev, next, isPrevRandom, isNextRandom } = await getAdjacentPosts(slug, locale); if (!post) { notFound(); } // Convert Lexical content into a plain string to estimate reading time roughly const rawTextContent = JSON.stringify(post.content); return (
{/* Featured Image Header */} {post.frontmatter.featuredImage ? (
{post.frontmatter.title}
{/* Title overlay on image */}
{post.frontmatter.category && (
{post.frontmatter.category}
)} {post.frontmatter.title}
{getReadingTime(rawTextContent)} min read {(new Date(post.frontmatter.date) > new Date() || post.frontmatter.public === false) && ( <> Draft Preview )}
) : (
{post.frontmatter.category && (
{post.frontmatter.category}
)} {post.frontmatter.title}
{getReadingTime(rawTextContent)} min read {(new Date(post.frontmatter.date) > new Date() || post.frontmatter.public === false) && ( <> Draft Preview )}
)} {/* Main Content Area with Sticky Narrative Layout */}
{/* Left Column: Content */}
{/* Excerpt/Lead paragraph if available */} {post.frontmatter.excerpt && (

{post.frontmatter.excerpt}

)} {/* Main content with enhanced styling rendering Payload Lexical */}
{/* Power CTA */}
{/* Post Navigation */}
{/* Back to blog link */}
{locale === 'de' ? 'Zurück zur Übersicht' : 'Back to Overview'}
{/* Right Column: Sticky Sidebar - Temporarily Hidden without ToC */}
{/* Structured Data */}
); }