feat(recipes): load recipe list from API in page server

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-03 09:45:43 +02:00
parent a733e8dd66
commit a25286e385
2 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import type { PageServerLoad } from './$types';
import { apiClient } from '$lib/server/api';
export const load: PageServerLoad = async ({ fetch }) => {
const api = apiClient(fetch);
const { data, error } = await api.GET('/v1/recipes', {});
if (error || !data?.data) {
return { recipes: [] };
}
return {
recipes: data.data.map((r) => ({
id: r.id!,
name: r.name!,
cookTimeMin: r.cookTimeMin,
effort: r.effort,
heroImageUrl: r.heroImageUrl
}))
};
};