Fix community IDs and update sitemap functionality
- Updated community IDs for various components in graph.json to reflect correct associations. - Added new function `getPublishedDoctors()` in app/sitemap.js and established relationships with existing functions. - Adjusted source locations for several functions in app/sitemap.js to ensure accurate mapping. - Enhanced canonical URL handling in lib/getCanonicalUrl.js to prevent incorrect canonicalization for paginated specialty pages. - Updated manifest.json with new modification times and AST hashes for affected files.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { cache } from "react";
|
||||
import { notFound } from "next/navigation";
|
||||
import Layout from "@/components/layout/StLayout";
|
||||
import SpecialtyDetailPage from "@/components/specialties/detail";
|
||||
@@ -16,7 +17,8 @@ const findSpecialty = (slug) =>
|
||||
specialtiesData.find((item) => item.slug === slug && item.status === 1) ?? null;
|
||||
|
||||
// روی هر دامنهٔ شهری این صفحه خودکار «تخصص + همان شهر» است — شهر از host میآید.
|
||||
async function getDoctors(specialtyId, cityId) {
|
||||
// cache تا generateMetadata و بدنهٔ صفحه یک بار fetch کنند، نه دو بار.
|
||||
const getDoctors = cache(async (specialtyId, cityId) => {
|
||||
try {
|
||||
const res = await fetchReq(`${API_URL}/api/v1/doctors`, {
|
||||
params: {
|
||||
@@ -33,7 +35,7 @@ async function getDoctors(specialtyId, cityId) {
|
||||
} catch {
|
||||
return { items: [], total: 0 };
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export async function generateMetadata({ params }) {
|
||||
const { slug } = await params;
|
||||
@@ -48,9 +50,15 @@ export async function generateMetadata({ params }) {
|
||||
const description = `لیست بهترین پزشکان ${specialty.name} در ${cityName} همراه با نشانی مطب، ساعات کاری و امتیاز بیماران. رزرو نوبت آنلاین متخصص ${specialty.name}.`;
|
||||
const image = "/assets/images/og-image.png";
|
||||
|
||||
// تخصصی که در این شهر پزشکی ندارد فقط یک عنوان و متن قالبی است — thin content.
|
||||
// ایندکس نمیشود (و در sitemap هم نمیآید)، ولی follow میماند تا لینکهای
|
||||
// داخلیاش دنبال شوند. بهمحض افزودهشدن اولین پزشک، خودکار ایندکسپذیر میشود.
|
||||
const { total } = await getDoctors(specialty.id, isRoot ? null : matchedCity?.id);
|
||||
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
...(total === 0 && { robots: { index: false, follow: true } }),
|
||||
// C1-a — صفحهٔ فرود تخصص per-domain است؛ canonical لایهٔ layout (self) درست است.
|
||||
openGraph: { title, description, images: [image] },
|
||||
twitter: { card: "summary_large_image", title, description, images: [image] },
|
||||
|
||||
Reference in New Issue
Block a user