i18n
This commit is contained in:
+23
-3
@@ -25,19 +25,39 @@ const config = {
|
||||
console.warn(`prerender skipped ${path}: ${message}`);
|
||||
},
|
||||
entries: (() => {
|
||||
// Locale lives in the path (see the paraglide config in vite.config.ts),
|
||||
// so a localized URL is not a route SvelteKit can discover on its own -
|
||||
// each one has to be listed. City pages are prerendered for the base
|
||||
// locale only; the other languages reach them through the SPA fallback,
|
||||
// which keeps the build from ballooning to cities × locales.
|
||||
const locales = ['en', 'de', 'es', 'fr', 'it'];
|
||||
const shared = [
|
||||
'/weather/week',
|
||||
'/weather/compare',
|
||||
'/weather/14-day',
|
||||
'/weather/seasonal',
|
||||
'/weather/historical',
|
||||
'/weather/maps',
|
||||
'/about',
|
||||
'/legal/imprint',
|
||||
'/legal/privacy',
|
||||
'/legal/terms'
|
||||
];
|
||||
const localized = locales.flatMap((locale) => shared.map((p) => `/${locale}${p}`));
|
||||
|
||||
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) => `/weather/week/${c}`);
|
||||
const cityEntries = cities.map((c) => `/en/weather/week/${c}`);
|
||||
// Keep the default wildcard to include other routes
|
||||
return ['*', ...cityEntries];
|
||||
return ['*', ...localized, ...cityEntries];
|
||||
}
|
||||
} catch {
|
||||
// If anything goes wrong, fall back to default behavior
|
||||
}
|
||||
return ['*'];
|
||||
return ['*', ...localized];
|
||||
})()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user