refactor: simplify search URL generation functions to return empty arrays
This commit is contained in:
+6
-132
@@ -84,146 +84,20 @@ function getStaticPages(baseUrl) {
|
||||
|
||||
// Generate doctor search URLs based on domain
|
||||
function getDoctorSearchUrls(domain, baseUrl) {
|
||||
const urls = [];
|
||||
|
||||
if (isMainDomain(domain)) {
|
||||
// For main domain, include all cities and limited specialties
|
||||
cityData.forEach(city => {
|
||||
const stateName = getStateById(city.province_id);
|
||||
if (stateName) {
|
||||
// City-only search
|
||||
const cityUrl = createSitemapUrl(baseUrl, '/doctors', {
|
||||
city: city.name,
|
||||
state: stateName
|
||||
});
|
||||
urls.push(createSitemapEntry(cityUrl, 0.8));
|
||||
|
||||
// City + specialty combinations (limited to prevent too many URLs)
|
||||
const limitedSpecialties = limitArray(specialtyData, DOMAIN_CONFIG.MAX_SPECIALTY_COMBINATIONS);
|
||||
limitedSpecialties.forEach(specialty => {
|
||||
const specialtyUrl = createSitemapUrl(baseUrl, '/doctors', {
|
||||
specialty: specialty.name,
|
||||
city: city.name,
|
||||
state: stateName
|
||||
});
|
||||
urls.push(createSitemapEntry(specialtyUrl, 0.7));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Specialty-only searches
|
||||
specialtyData.forEach(specialty => {
|
||||
const specialtyUrl = createSitemapUrl(baseUrl, '/doctors', {
|
||||
specialty: specialty.name
|
||||
});
|
||||
urls.push(createSitemapEntry(specialtyUrl, 0.8));
|
||||
});
|
||||
} else {
|
||||
// For city-specific domains, only include that city's data
|
||||
const currentCity = getCityByDomain(domain);
|
||||
if (currentCity) {
|
||||
const stateName = getStateById(currentCity.province_id);
|
||||
if (stateName) {
|
||||
// City-only search
|
||||
const cityUrl = createSitemapUrl(baseUrl, '/doctors', {
|
||||
city: currentCity.name,
|
||||
state: stateName
|
||||
});
|
||||
urls.push(createSitemapEntry(cityUrl, 0.8));
|
||||
|
||||
// City + specialty combinations
|
||||
specialtyData.forEach(specialty => {
|
||||
const specialtyUrl = createSitemapUrl(baseUrl, '/doctors', {
|
||||
specialty: specialty.name,
|
||||
city: currentCity.name,
|
||||
state: stateName
|
||||
});
|
||||
urls.push(createSitemapEntry(specialtyUrl, 0.7));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return urls;
|
||||
// Return empty array - no URLs with search parameters
|
||||
return [];
|
||||
}
|
||||
|
||||
// Generate clinic search URLs
|
||||
function getClinicSearchUrls(domain, baseUrl) {
|
||||
const urls = [];
|
||||
|
||||
if (isMainDomain(domain)) {
|
||||
// For main domain, include all cities
|
||||
cityData.forEach(city => {
|
||||
const stateName = getStateById(city.province_id);
|
||||
if (stateName) {
|
||||
const clinicUrl = createSitemapUrl(baseUrl, '/clinics', {
|
||||
city: city.name,
|
||||
state: stateName
|
||||
});
|
||||
urls.push(createSitemapEntry(clinicUrl, 0.8));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// For city-specific domains, only include that city
|
||||
const currentCity = getCityByDomain(domain);
|
||||
if (currentCity) {
|
||||
const stateName = getStateById(currentCity.province_id);
|
||||
if (stateName) {
|
||||
const clinicUrl = createSitemapUrl(baseUrl, '/clinics', {
|
||||
city: currentCity.name,
|
||||
state: stateName
|
||||
});
|
||||
urls.push(createSitemapEntry(clinicUrl, 0.8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return urls;
|
||||
// Return empty array - no URLs with search parameters
|
||||
return [];
|
||||
}
|
||||
|
||||
// Generate specialty pages URLs
|
||||
function getSpecialtyUrls(domain, baseUrl) {
|
||||
const urls = [];
|
||||
|
||||
if (isMainDomain(domain)) {
|
||||
// For main domain, include all specialties with main cities only (to prevent too many URLs)
|
||||
const mainCities = cityData.filter(city => DOMAIN_CONFIG.MAIN_CITIES.includes(city.id));
|
||||
|
||||
specialtyData.forEach(specialty => {
|
||||
// Base specialty page
|
||||
const specialtyUrl = createSitemapUrl(baseUrl, `/specialties/${encodeURIComponent(specialty.name)}`);
|
||||
urls.push(createSitemapEntry(specialtyUrl, 0.8));
|
||||
|
||||
// Specialty + city combinations (only for main cities)
|
||||
mainCities.forEach(city => {
|
||||
const stateName = getStateById(city.province_id);
|
||||
if (stateName) {
|
||||
const citySpecialtyUrl = createSitemapUrl(baseUrl, `/specialties/${encodeURIComponent(specialty.name)}`, {
|
||||
city: city.name,
|
||||
state: stateName
|
||||
});
|
||||
urls.push(createSitemapEntry(citySpecialtyUrl, 0.7));
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// For city-specific domains, include specialties with that city only
|
||||
const currentCity = getCityByDomain(domain);
|
||||
if (currentCity) {
|
||||
const stateName = getStateById(currentCity.province_id);
|
||||
if (stateName) {
|
||||
specialtyData.forEach(specialty => {
|
||||
const specialtyUrl = createSitemapUrl(baseUrl, `/specialties/${encodeURIComponent(specialty.name)}`, {
|
||||
city: currentCity.name,
|
||||
state: stateName
|
||||
});
|
||||
urls.push(createSitemapEntry(specialtyUrl, 0.7));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return urls;
|
||||
// Return empty array - no specialty URLs
|
||||
return [];
|
||||
}
|
||||
|
||||
export default async function sitemap() {
|
||||
|
||||
Reference in New Issue
Block a user