feat(seo): add school name to URLs, fix sticky nav, collapse compare widget
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>
This commit is contained in:
2026-03-29 12:41:28 +01:00
parent e2c700fcfc
commit 784febc162
12 changed files with 63 additions and 30 deletions

View File

@@ -20,6 +20,28 @@ export function slugify(text: string): string {
.trim();
}
/**
* Build a school URL path: /school/123456-school-name (capped at ~80 chars total)
*/
const MAX_SLUG_LENGTH = 60;
export function schoolUrl(urn: number, schoolName?: string): string {
if (!schoolName) return `/school/${urn}`;
let slug = slugify(schoolName);
if (slug.length > MAX_SLUG_LENGTH) {
slug = slug.slice(0, MAX_SLUG_LENGTH).replace(/-+$/, '');
}
return `/school/${urn}-${slug}`;
}
/**
* Extract the URN from a school slug (e.g. "138267-some-school-name" → 138267)
*/
export function parseSchoolSlug(slug: string): number | null {
const match = slug.match(/^(\d{6})/);
return match ? parseInt(match[1], 10) : null;
}
/**
* Escape HTML to prevent XSS
*/