diff --git a/src/routes/lists/[slug]/+page.server.ts b/src/routes/lists/[slug]/+page.server.ts index ccbe012..8f025af 100644 --- a/src/routes/lists/[slug]/+page.server.ts +++ b/src/routes/lists/[slug]/+page.server.ts @@ -21,6 +21,13 @@ import { and, eq, ne } from 'drizzle-orm'; import { error, fail, redirect } from '@sveltejs/kit'; import type { Actions, PageServerLoad } from './$types'; +/** Archived lists and where their old URL now points. Only used once the list is gone. */ +const RETIRED_LISTS: Record = { + 'books-to-read': '/trackers/books', + 'scientific-papers': '/trackers/books?kind=papers', + 'cars-trains-planes-to-spot': '/trackers/spotting' +}; + async function currentList(slug: string) { const list = await findList(slug); if (!list) error(404, 'List not found'); @@ -79,7 +86,12 @@ export const load: PageServerLoad = async ({ params }) => { } } const list = await getList(params.slug); - if (!list) error(404, 'List not found'); + if (!list) { + // Retired lists whose items moved into a tracker (or that were dropped) keep their URL. + const moved = RETIRED_LISTS[params.slug]; + if (moved) redirect(301, moved); + error(404, 'List not found'); + } const completedIds = list.isProgress ? list.items.filter((item) => item.doneAt).map((item) => item.id) : [];