fallback and 404

This commit is contained in:
Vincent van der Wal
2026-07-19 22:47:05 +02:00
parent baa4840b38
commit cd1a47b6c3
11 changed files with 580 additions and 212 deletions
+13 -1
View File
@@ -9,9 +9,21 @@ const config = {
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
adapter: adapter(),
// fallback: the SPA shell served for routes that were not prerendered
// (unlisted cities, GPS coordinate routes); the universal load then
// resolves the location client-side. Most static hosts serve 404.html
// for unknown paths automatically.
adapter: adapter({ fallback: '404.html' }),
// Pregenerate city pages to improve SEO during static build
prerender: {
// dynamic per-location routes (14-day, compare, unlisted cities) are
// served by the SPA fallback instead of being prerendered
handleUnseenRoutes: 'ignore',
// a transient geocoding failure for one city should skip that page
// (the fallback still serves it), not abort the whole build
handleHttpError: ({ path, message }) => {
console.warn(`prerender skipped ${path}: ${message}`);
},
entries: (() => {
try {
const citiesPath = path.resolve('src/routes/weather/locations/city-names100.json');