lists: retire scientific-papers (items live in /trackers/books?kind=papers) and cars-trains-planes-to-spot (-> /trackers/spotting); archived list URLs 301, books-to-read too
All checks were successful
Deploy production / deploy (push) Successful in 1m15s
All checks were successful
Deploy production / deploy (push) Successful in 1m15s
This commit is contained in:
@@ -21,6 +21,13 @@ import { and, eq, ne } from 'drizzle-orm';
|
|||||||
import { error, fail, redirect } from '@sveltejs/kit';
|
import { error, fail, redirect } from '@sveltejs/kit';
|
||||||
import type { Actions, PageServerLoad } from './$types';
|
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<string, string> = {
|
||||||
|
'books-to-read': '/trackers/books',
|
||||||
|
'scientific-papers': '/trackers/books?kind=papers',
|
||||||
|
'cars-trains-planes-to-spot': '/trackers/spotting'
|
||||||
|
};
|
||||||
|
|
||||||
async function currentList(slug: string) {
|
async function currentList(slug: string) {
|
||||||
const list = await findList(slug);
|
const list = await findList(slug);
|
||||||
if (!list) error(404, 'List not found');
|
if (!list) error(404, 'List not found');
|
||||||
@@ -79,7 +86,12 @@ export const load: PageServerLoad = async ({ params }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const list = await getList(params.slug);
|
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
|
const completedIds = list.isProgress
|
||||||
? list.items.filter((item) => item.doneAt).map((item) => item.id)
|
? list.items.filter((item) => item.doneAt).map((item) => item.id)
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
Reference in New Issue
Block a user