This commit is contained in:
Vincent van der Wal
2026-08-06 19:11:11 +02:00
parent 025623aaa6
commit f4a02a208c
21 changed files with 336 additions and 78 deletions
+15 -1
View File
@@ -45,12 +45,26 @@ const config = {
];
const localized = locales.flatMap((locale) => shared.map((p) => `/${locale}${p}`));
// Every per-location route, not just the week page: an unprerendered
// path is served by the SPA fallback, which the host answers with a
// 404 status. The page still works, but it costs a bogus 404 on every
// hard reload (and tells crawlers the page does not exist).
const cityRoutes = [
'/weather/week',
'/weather/compare',
'/weather/14-day',
'/weather/seasonal',
'/weather/historical'
];
try {
const citiesPath = path.resolve('src/routes/weather/locations/city-names100.json');
const raw = fs.readFileSync(citiesPath, 'utf-8');
const cities = JSON.parse(raw);
if (Array.isArray(cities)) {
const cityEntries = cities.map((c) => `/en/weather/week/${c}`);
const cityEntries = cities.flatMap((c) =>
cityRoutes.map((route) => `/en${route}/${c}`)
);
// Keep the default wildcard to include other routes
return ['*', ...localized, ...cityEntries];
}