Some checks failed
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 32s
Build and Push Docker Images / Build Frontend (Next.js) (push) Failing after 57s
Build and Push Docker Images / Build Pipeline (Meltano + dbt + Airflow) (push) Successful in 31s
Build and Push Docker Images / Trigger Portainer Update (push) Has been skipped
- URLs now /school/138267-school-name instead of /school/138267 - Bare URN URLs redirect to canonical slug (backward compat) - Remove overflow-x:hidden that broke sticky tab nav on secondary pages - ComparisonToast starts collapsed — user must click to open Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
/**
|
|
* Dynamic Sitemap Generation
|
|
* Generates sitemap with all school pages and main routes
|
|
*/
|
|
|
|
import { MetadataRoute } from 'next';
|
|
import { fetchSchools } from '@/lib/api';
|
|
import { schoolUrl } from '@/lib/utils';
|
|
|
|
const BASE_URL = 'https://schoolcompare.co.uk';
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
// Static pages
|
|
const staticPages: MetadataRoute.Sitemap = [
|
|
{
|
|
url: BASE_URL,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'daily',
|
|
priority: 1.0,
|
|
},
|
|
{
|
|
url: `${BASE_URL}/compare`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'weekly',
|
|
priority: 0.8,
|
|
},
|
|
{
|
|
url: `${BASE_URL}/rankings`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'weekly',
|
|
priority: 0.8,
|
|
},
|
|
];
|
|
|
|
// Fetch all schools (in batches if necessary)
|
|
try {
|
|
const schoolsData = await fetchSchools({
|
|
page: 1,
|
|
page_size: 10000, // Fetch all schools
|
|
});
|
|
|
|
const schoolPages: MetadataRoute.Sitemap = schoolsData.schools.map((school) => ({
|
|
url: `${BASE_URL}${schoolUrl(school.urn, school.school_name)}`,
|
|
lastModified: new Date(),
|
|
changeFrequency: 'monthly',
|
|
priority: 0.6,
|
|
}));
|
|
|
|
return [...staticPages, ...schoolPages];
|
|
} catch (error) {
|
|
console.error('Failed to generate sitemap:', error);
|
|
// Return just static pages if school fetch fails
|
|
return staticPages;
|
|
}
|
|
}
|