All checks were successful
CI / update (push) Successful in 4m3s
Client-side navigation to /recipes hung because getUserFavorites and other endpoints were hardcoded to /api/rezepte, causing fetch mismatches during SvelteKit's client-side routing.
26 lines
971 B
TypeScript
26 lines
971 B
TypeScript
import type { PageServerLoad } from "./$types";
|
|
import { getUserFavorites, addFavoriteStatusToRecipes } from "$lib/server/favorites";
|
|
|
|
export const load: PageServerLoad = async ({ fetch, locals, params }) => {
|
|
const apiBase = `/api/${params.recipeLang}`;
|
|
const currentMonth = new Date().getMonth() + 1;
|
|
|
|
// Fetch all_brief, favorites, and session in parallel
|
|
const [res_all_brief, userFavorites, session] = await Promise.all([
|
|
fetch(`${apiBase}/items/all_brief`).then(r => r.json()),
|
|
getUserFavorites(fetch, locals, params.recipeLang),
|
|
locals.auth()
|
|
]);
|
|
|
|
const all_brief = addFavoriteStatusToRecipes(res_all_brief, userFavorites);
|
|
// Derive seasonal subset from all_brief instead of a separate DB query
|
|
const season = all_brief.filter((r: any) => r.season?.includes(currentMonth) && r.icon !== '🍽️');
|
|
|
|
return {
|
|
season,
|
|
all_brief,
|
|
session,
|
|
heroIndex: Math.random()
|
|
};
|
|
};
|