import { projects } from '$lib/projects';
import type { PageServerLoad } from './$types';

export const load: PageServerLoad = async () => ({
	data: await Promise.all(
		[...projects.entries()].map(async ([path, load]) =>
			load().then(({ metadata }) => ({ path, ...metadata }))
		)
	).then((data) =>
		data.sort(({ date: a }, { date: z }) => new Date(z ?? 0).getTime() - new Date(a ?? 0).getTime())
	)
});
