45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
// 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;
|
|
}
|
|
|
|
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();
|
|
return queryString ? `${url}?${queryString}` : url;
|
|
}
|
|
|
|
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}`;
|
|
} |