- 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
35 lines
1.2 KiB
TypeScript
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} />;
|
|
}
|