feat(blog): enhance metadata generation and blog fetching by city context

This commit is contained in:
hamed
2026-07-19 09:02:14 +03:30
parent 88782e70c2
commit 4d7b87ee1a
5 changed files with 46 additions and 12 deletions
+11 -2
View File
@@ -31,12 +31,21 @@ export async function generateMetadata({ params }) {
if (!blog) notFound();
try {
// برند از شهرِ خودِ پست می‌آید، نه از دامنه‌ای که اتفاقاً آن را سرو می‌کند —
// وگرنه پست یاسوجی که روی دامنهٔ یزد باز شود عنوانش «یزد نوبت» می‌شد در حالی
// که canonical آن به یاسوج اشاره می‌کند. پست سراسری برند دامنهٔ جاری را می‌گیرد.
const blogCity = findCityById(extractEntityCityId(blog));
const brand = blogCity?.site_name || siteName;
const title = `${blog.title} | ${siteName}`;
const title = `${blog.title} | ${brand}`;
const rawText = (blog.summary || blog.body || "")
.replace(/<[^>]*>/g, "")
.trim();
const description = rawText.slice(0, 160) || blog.title;
const baseDescription = rawText.slice(0, 160) || blog.title;
// نام شهر فقط برای پست شهریافته؛ پست سراسری هیچ شهری نمی‌گیرد.
const description = blogCity
? `${baseDescription}`.slice(0, 150) + ` | ${blogCity.name}`
: baseDescription;
const image = blog.image_url ? imageUrl(blog.image_url) : FALLBACK_IMG;
// C1-b — پست شهریافته به دامنهٔ همان شهر canonical می‌شود؛