canina/frontend/application/app/blog/page.tsx
parsa aghaei 7615aa0e51 fix: resolve seed encoding, search param, and wiki data source issues
- Fix seed-products.ts TS error (implicit any) and BOM handling
- Re-run full seed to restore correct Persian encoding in DB
- Fix productService query→search param mismatch
- Fix IngredientWiki hardcoded port 4000→use settingsStore
- Restore seed-products-data.json from git after accidental corruption
2026-07-11 15:40:49 +03:30

35 lines
1.2 KiB
TypeScript

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 || 'http://localhost:4000';
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 <BlogPage blogs={blogs} />;
}