// Utility functions for sitemap generation export const DOMAIN_CONFIG = { MAIN_DOMAIN: 'nobat724.com', MAX_SPECIALTY_COMBINATIONS: 20, // Limit specialty combinations to prevent too many URLs MAIN_CITIES: ['108', '104', '111', '117', '113'], // Tehran, Isfahan, Mashhad, Shiraz, Ahvaz }; export function isMainDomain(domain) { return domain === DOMAIN_CONFIG.MAIN_DOMAIN || domain.includes('localhost') || domain.includes('127.0.0.1'); } export function encodeUrlParam(param) { return encodeURIComponent(param || ''); } export function createSitemapUrl(baseUrl, path, params = {}) { let url = `${baseUrl}${path}`; const searchParams = new URLSearchParams(); Object.entries(params).forEach(([key, value]) => { if (value) { searchParams.append(key, value); } }); const queryString = searchParams.toString(); const fullUrl = queryString ? `${url}?${queryString}` : url; // Escape XML entities return escapeXml(fullUrl); } export function escapeXml(str) { return str .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } export function createSitemapEntry(url, priority = 0.8, changeFrequency = 'weekly') { return { url, lastModified: new Date(), changeFrequency, priority, }; } export function limitArray(array, limit) { return limit > 0 ? array.slice(0, limit) : array; } export function getBaseUrl(domain) { return `https://${domain}`; }