feat: add doctorTitle helper function and update references in metadata and FAQ
This commit is contained in:
@@ -9,7 +9,7 @@ import { buildDoctorFaq } from "@/lib/specialtyContent";
|
|||||||
import { isThinDoctor } from "@/lib/entityQuality";
|
import { isThinDoctor } from "@/lib/entityQuality";
|
||||||
import specialtiesData from "@/data/specialties.json";
|
import specialtiesData from "@/data/specialties.json";
|
||||||
import { safeJsonLd } from "@/lib/sanitize";
|
import { safeJsonLd } from "@/lib/sanitize";
|
||||||
import { imageUrl } from "@/helper";
|
import { imageUrl, doctorTitle } from "@/helper";
|
||||||
|
|
||||||
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
||||||
const FALLBACK_IMG = "/assets/images/og-image.png";
|
const FALLBACK_IMG = "/assets/images/og-image.png";
|
||||||
@@ -71,14 +71,14 @@ export async function generateMetadata({ params }) {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
const specialtyNames = doctor.specialties?.map((s) => s.name).join(" و ") || "";
|
const specialtyNames = doctor.specialties?.map((s) => s.name).join(" و ") || "";
|
||||||
const title = `دکتر ${doctor.name}${specialtyNames ? " | " + specialtyNames : ""} | ${siteName}`;
|
const title = `${doctorTitle(doctor.name)}${specialtyNames ? " | " + specialtyNames : ""} | ${siteName}`;
|
||||||
const detailText = (doctor.detail || "")
|
const detailText = (doctor.detail || "")
|
||||||
.replace(/<[^>]*>/g, "")
|
.replace(/<[^>]*>/g, "")
|
||||||
.replace(/\s+/g, " ")
|
.replace(/\s+/g, " ")
|
||||||
.trim();
|
.trim();
|
||||||
const description = (
|
const description = (
|
||||||
detailText ||
|
detailText ||
|
||||||
`رزرو نوبت آنلاین دکتر ${doctor.name}${specialtyNames ? " متخصص " + specialtyNames : ""}${doctor.address ? " | " + doctor.address : ""}`.trim()
|
`رزرو نوبت آنلاین ${doctorTitle(doctor.name)}${specialtyNames ? " متخصص " + specialtyNames : ""}${doctor.address ? " | " + doctor.address : ""}`.trim()
|
||||||
).slice(0, 160);
|
).slice(0, 160);
|
||||||
const image = imageUrl(doctor.img?.[0]?.url) || FALLBACK_IMG;
|
const image = imageUrl(doctor.img?.[0]?.url) || FALLBACK_IMG;
|
||||||
// C1-b — پزشک به دامنهٔ شهر خودش canonical میشود، روی هر دامنهای که سرو شود.
|
// C1-b — پزشک به دامنهٔ شهر خودش canonical میشود، روی هر دامنهای که سرو شود.
|
||||||
@@ -172,7 +172,7 @@ async function Doctor({ params }) {
|
|||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
"@type": "Physician",
|
"@type": "Physician",
|
||||||
"@id": `${origin}/doctor/${doctor.uuid}#physician`,
|
"@id": `${origin}/doctor/${doctor.uuid}#physician`,
|
||||||
name: `دکتر ${doctor.name}`,
|
name: doctorTitle(doctor.name),
|
||||||
url: `${origin}/doctor/${doctor.uuid}`,
|
url: `${origin}/doctor/${doctor.uuid}`,
|
||||||
...(specialtyNames && { medicalSpecialty: specialtyNames }),
|
...(specialtyNames && { medicalSpecialty: specialtyNames }),
|
||||||
...(doctor.img?.[0]?.url && {
|
...(doctor.img?.[0]?.url && {
|
||||||
@@ -212,7 +212,7 @@ async function Doctor({ params }) {
|
|||||||
...(bookableAddresses.length > 0 && {
|
...(bookableAddresses.length > 0 && {
|
||||||
workLocation: bookableAddresses.map((addr) => ({
|
workLocation: bookableAddresses.map((addr) => ({
|
||||||
"@type": "MedicalClinic",
|
"@type": "MedicalClinic",
|
||||||
name: addr.clinic_name || addr.name || `مطب دکتر ${doctor.name}`,
|
name: addr.clinic_name || addr.name || `مطب ${doctorTitle(doctor.name)}`,
|
||||||
address: {
|
address: {
|
||||||
"@type": "PostalAddress",
|
"@type": "PostalAddress",
|
||||||
streetAddress: addr.address,
|
streetAddress: addr.address,
|
||||||
@@ -254,7 +254,7 @@ async function Doctor({ params }) {
|
|||||||
itemListElement: [
|
itemListElement: [
|
||||||
{ "@type": "ListItem", position: 1, name: "خانه", item: origin },
|
{ "@type": "ListItem", position: 1, name: "خانه", item: origin },
|
||||||
{ "@type": "ListItem", position: 2, name: specialtyLabel, item: specialtyItem },
|
{ "@type": "ListItem", position: 2, name: specialtyLabel, item: specialtyItem },
|
||||||
{ "@type": "ListItem", position: 3, name: `دکتر ${doctor.name}` },
|
{ "@type": "ListItem", position: 3, name: doctorTitle(doctor.name) },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
|||||||
@@ -46,6 +46,13 @@ export const imageUrl = (url, fallback = "/assets/images/user.png") => {
|
|||||||
return url;
|
return url;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// نام پزشک با پیشوند «دکتر»، بدون تکرار. بعضی رکوردها خودشان با «دکتر»/«دکتر.»
|
||||||
|
// ذخیره شدهاند؛ بدون این نرمالسازی خروجی «دکتر دکتر ...» میشود.
|
||||||
|
export const doctorTitle = (name) => {
|
||||||
|
const clean = (name || "").trim().replace(/^(دکتر|دكتر)[.،:]?\s+/, "");
|
||||||
|
return clean ? `دکتر ${clean}` : "";
|
||||||
|
};
|
||||||
|
|
||||||
export const convertToJalali = (date) => {
|
export const convertToJalali = (date) => {
|
||||||
const currentDate = date;
|
const currentDate = date;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
// متفاوت استفاده میشود که با هشِ (تخصص، شهر) انتخاب میشوند — خروجی پایدار
|
// متفاوت استفاده میشود که با هشِ (تخصص، شهر) انتخاب میشوند — خروجی پایدار
|
||||||
// (بین دو رندر تغییر نمیکند) ولی بین صفحات مختلف واگراست.
|
// (بین دو رندر تغییر نمیکند) ولی بین صفحات مختلف واگراست.
|
||||||
|
|
||||||
|
import { doctorTitle } from "@/helper";
|
||||||
|
|
||||||
function hash(...parts) {
|
function hash(...parts) {
|
||||||
const key = parts.join("|");
|
const key = parts.join("|");
|
||||||
let value = 0;
|
let value = 0;
|
||||||
@@ -63,7 +65,7 @@ export function buildSpecialtyIntro(specialtyName, cityName, doctorCount = 0) {
|
|||||||
|
|
||||||
/** سوالات متداول صفحهٔ پزشک — منبع مشترک بلوک بصری و FAQPage schema. */
|
/** سوالات متداول صفحهٔ پزشک — منبع مشترک بلوک بصری و FAQPage schema. */
|
||||||
export function buildDoctorFaq(doctorName, specialtyName, cityName) {
|
export function buildDoctorFaq(doctorName, specialtyName, cityName) {
|
||||||
const who = `دکتر ${doctorName}`;
|
const who = doctorTitle(doctorName);
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
question: `چگونه از ${who} نوبت بگیرم؟`,
|
question: `چگونه از ${who} نوبت بگیرم؟`,
|
||||||
|
|||||||
Reference in New Issue
Block a user