feat(robots): update disallow rules to include '/panel' feat(sitemap): implement separate sitemaps for doctors, clinics, and blogs feat(icons): add social media icons for doctor profiles
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
const API_URL = process.env.NEXT_PUBLIC_API_URL;
|
|
const MAIN_DOMAIN = 'https://nobat724.com';
|
|
const PER_SITEMAP = 1000;
|
|
|
|
export async function generateSitemaps() {
|
|
if (!API_URL) return [{ id: 0 }];
|
|
|
|
try {
|
|
const res = await fetch(`${API_URL}/api/v1/doctors?page=1&limit=1`, {
|
|
next: { revalidate: 86400 },
|
|
});
|
|
if (!res.ok) return [{ id: 0 }];
|
|
const json = await res.json();
|
|
const total = json?.meta?.totalRecords || 0;
|
|
const pageCount = Math.max(1, Math.ceil(total / PER_SITEMAP));
|
|
return Array.from({ length: pageCount }, (_, id) => ({ id }));
|
|
} catch {
|
|
return [{ id: 0 }];
|
|
}
|
|
}
|
|
|
|
export default async function sitemap({ id }) {
|
|
if (!API_URL) return [];
|
|
|
|
try {
|
|
const res = await fetch(`${API_URL}/api/v1/doctors?page=${id + 1}&limit=${PER_SITEMAP}`, {
|
|
next: { revalidate: 3600 },
|
|
});
|
|
if (!res.ok) return [];
|
|
const json = await res.json();
|
|
const doctors = json?.data || [];
|
|
return doctors
|
|
.filter((d) => d?.uuid)
|
|
.map((d) => ({
|
|
url: `${MAIN_DOMAIN}/doctor/${d.uuid}`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'weekly',
|
|
priority: 0.8,
|
|
}));
|
|
} catch {
|
|
return [];
|
|
}
|
|
}
|