From cb9505ff459060ea55810116f242f68183a478d0 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Fri, 2 Jan 2026 13:05:51 +0100 Subject: [PATCH] fix: correct images field to be array in recipe creation The images field was incorrectly set as a single object instead of an array, causing translation to fail with 'images.forEach is not a function' error. Also added defensive Array.isArray check in translation service. --- src/routes/[recipeLang=recipeLang]/add/+page.svelte | 2 +- src/utils/translation.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/[recipeLang=recipeLang]/add/+page.svelte b/src/routes/[recipeLang=recipeLang]/add/+page.svelte index f6579dd..5cb17bf 100644 --- a/src/routes/[recipeLang=recipeLang]/add/+page.svelte +++ b/src/routes/[recipeLang=recipeLang]/add/+page.svelte @@ -108,7 +108,7 @@ return { ...card_data, ...add_info, - images: {mediapath: short_name.trim() + '.webp', alt: "", caption: ""}, + images: [{mediapath: short_name.trim() + '.webp', alt: "", caption: ""}], season: season_local, short_name : short_name.trim(), portions: portions_local, diff --git a/src/utils/translation.ts b/src/utils/translation.ts index 87877a6..1163bac 100644 --- a/src/utils/translation.ts +++ b/src/utils/translation.ts @@ -325,7 +325,7 @@ class DeepLTranslationService { }); // Add image alt and caption texts - const images = recipe.images || []; + const images = Array.isArray(recipe.images) ? recipe.images : []; images.forEach((img: any) => { textsToTranslate.push(img.alt || ''); textsToTranslate.push(img.caption || '');