import { Metadata } from 'next' import { notFound } from 'next/navigation' import { Link } from '@/src/i18n/navigation' import { getAllPosts, getPostBySlug, getRelatedPosts } from '@/lib/markdown' import { formatDate } from '@/lib/utils' import { TableOfContents } from '@/components/blog/table-of-contents' import { ReadingProgress } from '@/components/blog/reading-progress' import { StickyFooter } from '@/components/blog/sticky-footer' import MarkdownRenderer from '@/components/blog/markdown-renderer' export async function generateStaticParams() { const locales = ['en', 'ro'] const allParams: Array<{ locale: string; slug: string[] }> = [] for (const locale of locales) { const posts = await getAllPosts(locale) posts.forEach(post => { allParams.push({ locale, slug: post.slug.split('/') }) }) } return allParams } export async function generateMetadata({ params, }: { params: Promise<{ locale: string; slug: string[] }> }): Promise { const { slug, locale } = await params const slugPath = slug.join('/') const post = await getPostBySlug(slugPath, locale) 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 extractHeadings(content: string) { const headingRegex = /^(#{2,3})\s+(.+)$/gm const headings: { id: string; text: string; level: number }[] = [] let match while ((match = headingRegex.exec(content)) !== null) { const level = match[1].length const text = match[2] const id = text .toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/(^-|-$)/g, '') headings.push({ id, text, level }) } return headings } export default async function BlogPostPage({ params, }: { params: Promise<{ locale: string; slug: string[] }> }) { const { slug, locale } = await params const slugPath = slug.join('/') const post = await getPostBySlug(slugPath, locale) if (!post) { notFound() } const relatedPosts = await getRelatedPosts(slugPath) const headings = extractHeadings(post.content) const fullUrl = `${process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3030'}/blog/${slugPath}` return ( <>

>> _DOC://PUBLIC_ACCESS

{post.frontmatter.tags.map((tag: string) => ( #{tag} ))}

{post.frontmatter.title}

>>{' '} {post.frontmatter.description}

{post.frontmatter.author.charAt(0).toUpperCase()}

{post.frontmatter.author}

// {post.readingTime}min READ
{post.frontmatter.image && (
{post.frontmatter.title}
)}
{relatedPosts.length > 0 && (

// Articole similare

{relatedPosts.map(relatedPost => (

{relatedPost.frontmatter.title}

{relatedPost.frontmatter.description}

{formatDate(relatedPost.frontmatter.date)}

))}
)}
) }