fix: include images in all_brief API endpoints
All checks were successful
CI / update (push) Successful in 1m23s
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:
@@ -10,7 +10,7 @@ export const GET: RequestHandler = async ({params}) => {
|
||||
// Find all recipes that have approved English translations
|
||||
const recipes = await Recipe.find(
|
||||
{ 'translations.en.translationStatus': 'approved' },
|
||||
'_id translations.en short_name season dateModified icon'
|
||||
'_id translations.en short_name season dateModified icon images'
|
||||
).lean();
|
||||
|
||||
// Map to brief format with English data
|
||||
@@ -24,7 +24,8 @@ export const GET: RequestHandler = async ({params}) => {
|
||||
description: recipe.translations.en.description,
|
||||
season: recipe.season || [],
|
||||
dateModified: recipe.dateModified,
|
||||
germanShortName: recipe.short_name // For language switcher
|
||||
germanShortName: recipe.short_name, // For language switcher
|
||||
images: recipe.images || []
|
||||
})) as BriefRecipeType[];
|
||||
|
||||
return json(JSON.parse(JSON.stringify(rand_array(found_brief))));
|
||||
|
||||
@@ -17,7 +17,7 @@ export const GET: RequestHandler = async ({params}) => {
|
||||
} else {
|
||||
// Cache miss - fetch from DB
|
||||
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)
|
||||
await cache.set(cacheKey, JSON.stringify(recipes), 3600);
|
||||
|
||||
Reference in New Issue
Block a user