overlay
This commit is contained in:
+15
-1
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user