- Implemented canonical URL strategies for city-specific domains and entities. - Added helper functions for domain and city resolution. - Created tests for canonical URL generation and domain resolution. - Introduced entity quality checks for doctors and clinics to ensure meaningful content. - Developed unique introductory texts for listing pages to avoid duplicate content. - Established robots.txt policies for listing pages to manage indexing based on user filters. - Enhanced specialty content with dynamic introductions and FAQs to improve SEO.
88 lines
3.1 KiB
JavaScript
88 lines
3.1 KiB
JavaScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import ListDoctors from "./listDoctors";
|
|
import { useSearchParams } from "next/navigation";
|
|
import Head from "./head";
|
|
import specialties from "@/data/specialties.json";
|
|
import states from "@/data/state.json";
|
|
import cities from "@/data/city.json";
|
|
import { isRootCity } from "@/lib/rootCity";
|
|
import { resolveCityDisplayName } from "@/lib/domainHelpers";
|
|
import { buildDoctorsIntro } from "@/lib/listingIntro";
|
|
|
|
function DoctorsPage({ matchedCity, matchedState, list }) {
|
|
const searchParams = useSearchParams();
|
|
const [page, setPage] = useState(list?.meta?.currentPage || 1);
|
|
const [doctors, setDoctors] = useState(list?.data);
|
|
const fieldName = searchParams.get("specialty");
|
|
|
|
const findItem = (key, name) =>
|
|
specialties.find((item) => item[key] === name);
|
|
const isParent =
|
|
findItem("name", fieldName) && findItem("name", fieldName).parent_id;
|
|
|
|
const isRoot = isRootCity(matchedCity);
|
|
const selectedState =
|
|
searchParams.get("state") || (!isRoot ? matchedState?.name : undefined);
|
|
const selectedCity =
|
|
searchParams.get("city") ||
|
|
(matchedCity?.name && !isRoot ? matchedCity?.name : false);
|
|
|
|
const valCategory = isParent
|
|
? findItem("id", isParent)
|
|
: findItem("name", fieldName);
|
|
const valSpecialty = isParent && findItem("name", fieldName);
|
|
|
|
const defaultFilter = {
|
|
state: selectedState && states.find((item) => item.name === selectedState),
|
|
city: selectedCity && cities.find((item) => item.name === selectedCity),
|
|
category: valCategory,
|
|
specialty: valSpecialty,
|
|
active: Number(searchParams.get("active")) || 0,
|
|
gender: searchParams.get("gender") || "هر دو",
|
|
degree: searchParams.get("degree") || "همه موارد",
|
|
sort: (searchParams.get("sort") && Number(searchParams.get("sort"))) || "",
|
|
name:
|
|
searchParams.get("name") || valSpecialty?.name || valCategory?.name || "",
|
|
};
|
|
|
|
const [filter, setFilter] = useState(defaultFilter);
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
return (
|
|
<div className="pt-[95px] sm:pt-[120px] padding-responsive">
|
|
{/* h1 واقعی صفحه — تایپوگرافی همان عنوان صفحات لیست (HeadPageList) */}
|
|
<h1 className="text-[#3B3B3B] text-[16px] sm:text-[19px] md:text-[22px] lg:text-[24px] text-center font-bold">
|
|
پزشکان و متخصصان {resolveCityDisplayName(matchedCity)} | رزرو نوبت آنلاین
|
|
</h1>
|
|
<p className="text-[#525252] text-[14px] md:text-[16px] font-normal leading-8 mt-[16px] text-justify">
|
|
{buildDoctorsIntro(resolveCityDisplayName(matchedCity))}
|
|
</p>
|
|
<Head
|
|
limit={12}
|
|
filter={filter}
|
|
setPage={setPage}
|
|
setFilter={setFilter}
|
|
setDoctors={setDoctors}
|
|
setLoading={setLoading}
|
|
matchedCity={matchedCity}
|
|
matchedState={matchedState}
|
|
/>
|
|
<ListDoctors
|
|
limit={12}
|
|
data={list}
|
|
page={page}
|
|
filter={filter}
|
|
setPage={setPage}
|
|
doctors={doctors}
|
|
loading={loading}
|
|
setLoading={setLoading}
|
|
setDoctors={setDoctors}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default DoctorsPage;
|