import { error } from '@sveltejs/kit';
import { getArchives, getArchive } from '$lib/server/archives';
import type { EntryGenerator } from './$types';

export const entries: EntryGenerator = () => getArchives().map((a) => ({ slug: a.slug }));

export function load({ params }) {
	const archive = getArchive(params.slug);
	if (!archive) error(404, 'Numéro introuvable');
	return { archive };
}
