fix: include images in all_brief API endpoints
All checks were successful
CI / update (push) Successful in 1m23s

Card.svelte uses recipe.images[0].mediapath for the hashed image path,
but the all_brief endpoints weren't fetching the images field, causing
new recipes to fall back to short_name.webp instead of the correct path.
This commit is contained in:
2026-01-29 13:40:31 +01:00
parent 763edb35c3
commit 308d9c6dac
2 changed files with 4 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ export const GET: RequestHandler = async ({params}) => {
// Find all recipes that have approved English translations // Find all recipes that have approved English translations
const recipes = await Recipe.find( const recipes = await Recipe.find(
{ 'translations.en.translationStatus': 'approved' }, { 'translations.en.translationStatus': 'approved' },
'_id translations.en short_name season dateModified icon' '_id translations.en short_name season dateModified icon images'
).lean(); ).lean();
// Map to brief format with English data // Map to brief format with English data
@@ -24,7 +24,8 @@ export const GET: RequestHandler = async ({params}) => {
description: recipe.translations.en.description, description: recipe.translations.en.description,
season: recipe.season || [], season: recipe.season || [],
dateModified: recipe.dateModified, dateModified: recipe.dateModified,
germanShortName: recipe.short_name // For language switcher germanShortName: recipe.short_name, // For language switcher
images: recipe.images || []
})) as BriefRecipeType[]; })) as BriefRecipeType[];
return json(JSON.parse(JSON.stringify(rand_array(found_brief)))); return json(JSON.parse(JSON.stringify(rand_array(found_brief))));

View File

@@ -17,7 +17,7 @@ export const GET: RequestHandler = async ({params}) => {
} else { } else {
// Cache miss - fetch from DB // Cache miss - fetch from DB
await dbConnect(); await dbConnect();
recipes = await Recipe.find({}, 'name short_name tags category icon description season dateModified').lean() as BriefRecipeType[]; recipes = await Recipe.find({}, 'name short_name tags category icon description season dateModified images').lean() as BriefRecipeType[];
// Store in cache (1 hour TTL) // Store in cache (1 hour TTL)
await cache.set(cacheKey, JSON.stringify(recipes), 3600); await cache.set(cacheKey, JSON.stringify(recipes), 3600);