import BlogPage from "../../components/BlogPage"; import type { Metadata } from 'next'; export const metadata: Metadata = { title: 'مجله سلامت حیوانات خانگی', description: 'آخرین مقالات، آموزش‌ها و اخبار علمی در زمینه نگهداری، تغذیه و سلامت سگ و گربه.', }; async function getBlogs() { const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'https://apicanina.parsaaghayi.ir'; try { const res = await fetch(`${apiUrl}/api/blogs`, { next: { revalidate: 60 } }); if (!res.ok) throw new Error('Failed to fetch blogs'); const data = await res.json(); return (data.data || data).map((b: any) => ({ id: b.id, slug: b.slug, title: b.title, excerpt: b.metaDescription || b.content.substring(0, 150).replace(/<[^>]+>/g, '') + '...', image: b.imageUrl, date: new Date(b.createdAt).toLocaleDateString('fa-IR'), author: b.author ? `${b.author.firstName} ${b.author.lastName}` : 'نویسنده کانینا', content: b.content })); } catch (error) { console.error(error); return []; } } export default async function Blog() { const blogs = await getBlogs(); return ; }