import { Metadata } from 'next' import { notFound } from 'next/navigation' import Link from 'next/link' import { getAllPosts, getPostBySlug, getRelatedPosts } from '@/lib/markdown' import { formatDate, formatRelativeDate } from '@/lib/utils' export async function generateStaticParams() { const posts = await getAllPosts() return posts.map((post) => ({ slug: post.slug.split('/') })) } export async function generateMetadata({ params }: { params: Promise<{ slug: string[] }> }): Promise { const { slug } = await params const slugPath = slug.join('/') const post = getPostBySlug(slugPath) if (!post) { return { title: 'Articol negăsit' } } return { title: post.frontmatter.title, description: post.frontmatter.description, authors: [{ name: post.frontmatter.author }], openGraph: { title: post.frontmatter.title, description: post.frontmatter.description, type: 'article', publishedTime: post.frontmatter.date, authors: [post.frontmatter.author], images: post.frontmatter.image ? [post.frontmatter.image] : [], }, twitter: { card: 'summary_large_image', title: post.frontmatter.title, description: post.frontmatter.description, images: post.frontmatter.image ? [post.frontmatter.image] : [], }, } } function AuthorInfo({ author, date }: { author: string; date: string }) { return (
{author.charAt(0).toUpperCase()}

{author}

Publicat {formatRelativeDate(date)} • {formatDate(date)}

) } function RelatedPosts({ posts }: { posts: any[] }) { if (posts.length === 0) return null return (

Articole similare

{posts.map((post) => (

{post.frontmatter.title}

{post.frontmatter.description}

{formatDate(post.frontmatter.date)}

))}
) } export default async function BlogPostPage({ params }: { params: Promise<{ slug: string[] }> }) { const { slug } = await params const slugPath = slug.join('/') const post = getPostBySlug(slugPath) if (!post) { notFound() } const relatedPosts = await getRelatedPosts(slugPath) return (
{post.frontmatter.image && ( {post.frontmatter.title} )}

{post.frontmatter.title}

{post.frontmatter.description}

{post.frontmatter.tags && post.frontmatter.tags.length > 0 && (
{post.frontmatter.tags.map((tag: string) => ( #{tag} ))}
)}
Timp estimat de citire: {post.readingTime} minute
) }