import * as React from "react"; import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { getAllPosts } from "../../../src/lib/posts"; import { BlogPostHeader } from "../../../src/components/blog/BlogPostHeader"; import { Section } from "../../../src/components/Section"; import { Reveal } from "../../../src/components/Reveal"; import { BlogPostClient } from "../../../src/components/BlogPostClient"; import { TextSelectionShare } from "../../../src/components/TextSelectionShare"; import { BlogPostStickyBar } from "../../../src/components/blog/BlogPostStickyBar"; import { MDXContent } from "../../../src/components/MDXContent"; export async function generateStaticParams() { const allPosts = await getAllPosts(); return allPosts.map((post) => ({ slug: post.slug, })); } export async function generateMetadata({ params, }: { params: Promise<{ slug: string }>; }): Promise { const { slug } = await params; const allPosts = await getAllPosts(); const post = allPosts.find((p) => p.slug === slug); if (!post) return {}; return { title: post.title, description: post.description, openGraph: { title: post.title, description: post.description, type: "article", }, twitter: { card: "summary_large_image", title: post.title, description: post.description, }, }; } export default async function BlogPostPage({ params, }: { params: Promise<{ slug: string }>; }) { const { slug } = await params; const allPosts = await getAllPosts(); const post = allPosts.find((p) => p.slug === slug); if (!post) { notFound(); } const formattedDate = new Date(post.date).toLocaleDateString("de-DE", { month: "long", day: "numeric", year: "numeric", }); const wordCount = post.description.split(/\s+/).length + 300; const readingTime = Math.max(1, Math.ceil(wordCount / 200)); return (
{post.tags && post.tags.length > 0 && (
{post.tags?.map((tag) => ( #{tag} ))}
)}
); }