import Link from "next/link"; import Breadcrumb from "@/app/components/Breadcrumb"; import NewsDetailsSection from "./components/NewsDetailsSection"; import { fetchBlogList, fetchBlogDetail } from "@/api/blog"; import Sidebar from "@/app/blog/components/Sidebar"; // Generate static params for all blog posts export async function generateStaticParams() { try { const blogResponse = await fetchBlogList({ page: 1, limit: 100 }); return blogResponse.data.blogs.map((post) => ({ slug: post.slug, })); } catch (error) { console.error("Error generating static params:", error); return []; } } interface BlogDetailsPageProps { params: Promise<{ slug: string; }> | { slug: string; }; } export default async function BlogDetailsPage({ params }: BlogDetailsPageProps) { // Handle both Promise and direct object const resolvedParams = params instanceof Promise ? await params : params; const slug = resolvedParams.slug; // Fetch blog detail from API let blogResponse; try { blogResponse = await fetchBlogDetail(slug); } catch { return ( <>

Post not found

The blog post you are looking for does not exist.

Back to Blog
{/* Sidebar on the right */}
); } const post = blogResponse.data; return ( <> ); }