import { getPostData, getAllPostSlugs } from '@/lib/posts'; import { notFound } from 'next/navigation'; import Link from 'next/link'; import "@/app/markdown.css"; interface PostPageProps { params: Promise<{ slug: string }>; } export async function generateStaticParams() { const slugs = getAllPostSlugs(); console.log('Генерация статических путей для slugs:', slugs); return slugs.map((slug) => ({ slug, })); } export async function generateMetadata({ params }: PostPageProps) { const { slug } = await params; const post = await getPostData(slug); if (!post) { return { title: 'Пост не найден', }; } return { title: post.title, description: post.description, }; } export default async function PostPage({ params }: PostPageProps) { const { slug } = await params; const post = await getPostData(slug); console.log(`Загрузка поста: ${slug}, результат:`, post ? 'найден' : 'не найден'); if (!post) { notFound(); } const formatDate = (dateStr: string) => { try { const date = new Date(dateStr); return new Intl.DateTimeFormat('ru-RU', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', }).format(date); } catch { return dateStr; } }; return ( <>
Опубликовано
{formatDate(post.date)}

{post.title}

{post.tags.length > 0 && (
{post.tags.map((tag) => ( {tag} ))}
)}
); }