feat(doctor): enhance doctor schema with addresses, ratings, and social media links

feat(robots): update disallow rules to include '/panel'
feat(sitemap): implement separate sitemaps for doctors, clinics, and blogs
feat(icons): add social media icons for doctor profiles
This commit is contained in:
hamed
2026-06-21 12:35:15 +03:30
parent 93b2710ae1
commit a8c3a57114
10 changed files with 540 additions and 97 deletions
+58 -5
View File
@@ -20,6 +20,19 @@ const getDoctor = cache(async (slug) => {
}
});
const getDoctorAddresses = cache(async (doctorId) => {
try {
const res = await fetch(`${API_URL}/api/v1/clinic-pro/doctor-addresses/${doctorId}`, {
next: { revalidate: 3600, tags: [`doctor-addresses-${doctorId}`] },
});
if (!res.ok) return [];
const json = await res.json();
return json?.data ?? [];
} catch {
return [];
}
});
export async function generateMetadata({ params }) {
const { slug } = await params;
const { matchedCity } = await getStateInfo();
@@ -79,20 +92,60 @@ async function Doctor({ params }) {
} catch (error) {}
}
const addresses = doctor ? await getDoctorAddresses(doctor.id) : [];
const specialtyNames = doctor?.specialties?.map((s) => s.name).join(" و ") || "";
const jsonLd = doctor
? {
"@context": "https://schema.org",
"@type": "Physician",
"@id": `https://www.nobat724.com/doctor/${doctor.uuid}#physician`,
name: `دکتر ${doctor.name}`,
url: `https://www.nobat724.com/doctor/${doctor.uuid}`,
...(specialtyNames && { medicalSpecialty: specialtyNames }),
...(doctor.img && { image: doctor.img }),
...(doctor.address && {
address: {
"@type": "PostalAddress",
streetAddress: doctor.address,
...(doctor.img && {
image: {
"@type": "ImageObject",
url: imageUrl(doctor.img),
},
}),
...(Number(doctor.point) > 0 && {
aggregateRating: {
"@type": "AggregateRating",
ratingValue: doctor.point,
bestRating: "5",
ratingCount: comments?.length || 1,
},
}),
...(comments?.length > 0 && {
review: comments.slice(0, 5).map((c) => ({
"@type": "Review",
author: { "@type": "Person", name: c.author?.real_name || "بیمار" },
reviewBody: c.comment,
datePublished: new Date(c.created * 1000).toISOString(),
})),
}),
...(doctor.social_media && {
sameAs: Object.values(doctor.social_media).filter(Boolean),
}),
...(addresses.length > 0 && {
workLocation: addresses.map((addr) => ({
"@type": "MedicalClinic",
name: addr.clinic_name || addr.name || `مطب دکتر ${doctor.name}`,
address: {
"@type": "PostalAddress",
streetAddress: addr.address,
},
...(addr.telephone && { telephone: addr.telephone }),
...(addr.map?.latitude && addr.map?.longitude && {
geo: {
"@type": "GeoCoordinates",
latitude: addr.map.latitude,
longitude: addr.map.longitude,
},
}),
})),
}),
}
: null;