import { notFound, redirect } from 'next/navigation';
import JsonLd from '@/components/JsonLd';
import { SITE_URL } from '@/lib/schema';
import {
getPostBySlug,
getAdjacentPosts,
getReadingTime,
getHeadings,
} 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 TableOfContents from '@/components/blog/TableOfContents';
import { Heading } from '@/components/ui';
import { setRequestLocale } from 'next-intl/server';
import BlogEngagementTracker from '@/components/analytics/BlogEngagementTracker';
import { MDXRemote } from 'next-mdx-remote/rsc';
const mdxComponents = {
Heading,
h1: (props: any) => , // Hidden because Hero handles H1
h2: (props: any) => ,
h3: (props: any) => ,
h4: (props: any) => ,
p: (props: any) =>
,
ul: (props: any) => ,
ol: (props: any) =>
,
li: (props: any) => (
),
a: (props: any) => ,
strong: (props: any) => ,
blockquote: (props: any) => (
),
hr: (props: any) =>
,
img: (props: any) =>
,
};
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/${post.slug}`,
},
openGraph: {
title: `${post.frontmatter.title} | E-TIB`,
description: description,
type: 'article',
publishedTime: post.frontmatter.date,
authors: ['E-TIB'],
url: `${SITE_URL}/${locale}/blog/${post.slug}`,
},
twitter: {
card: 'summary_large_image',
title: `${post.frontmatter.title} | E-TIB`,
description: description,
},
};
}
export default async function BlogPost({ params }: BlogPostProps) {
const { locale, slug } = await params;
setRequestLocale(locale);
const post = await getPostBySlug(slug, locale);
if (!post) {
notFound();
}
const { prev, next, isPrevRandom, isNextRandom } = await getAdjacentPosts(post.slug, locale);
const headings = getHeadings(post.content);
const readingTime = getReadingTime(post.content);
return (
{/* Featured Image Header */}
{post.frontmatter.featuredImage ? (
{/* Title overlay on image */}
{post.frontmatter.category && (
{post.frontmatter.category}
)}
{post.frontmatter.title}
{readingTime} min read
{(new Date(post.frontmatter.date) > new Date() ||
post.frontmatter.public === false) && (
<>
Draft Preview
>
)}
) : (
{post.frontmatter.category && (
{post.frontmatter.category}
)}
{post.frontmatter.title}
{readingTime} 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 */}
{/* Power CTA */}
{/* Post Navigation */}
{/* Back to blog link */}
{locale === 'de' ? 'Zurück zur Übersicht' : 'Back to Overview'}
{/* Right Column: Sticky Sidebar - TOC */}
{/* Structured Data */}
);
}