fix: correct images field to be array in recipe creation
All checks were successful
CI / update (push) Successful in 2m49s
All checks were successful
CI / update (push) Successful in 2m49s
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.
This commit is contained in:
@@ -108,7 +108,7 @@
|
|||||||
return {
|
return {
|
||||||
...card_data,
|
...card_data,
|
||||||
...add_info,
|
...add_info,
|
||||||
images: {mediapath: short_name.trim() + '.webp', alt: "", caption: ""},
|
images: [{mediapath: short_name.trim() + '.webp', alt: "", caption: ""}],
|
||||||
season: season_local,
|
season: season_local,
|
||||||
short_name : short_name.trim(),
|
short_name : short_name.trim(),
|
||||||
portions: portions_local,
|
portions: portions_local,
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ class DeepLTranslationService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add image alt and caption texts
|
// Add image alt and caption texts
|
||||||
const images = recipe.images || [];
|
const images = Array.isArray(recipe.images) ? recipe.images : [];
|
||||||
images.forEach((img: any) => {
|
images.forEach((img: any) => {
|
||||||
textsToTranslate.push(img.alt || '');
|
textsToTranslate.push(img.alt || '');
|
||||||
textsToTranslate.push(img.caption || '');
|
textsToTranslate.push(img.caption || '');
|
||||||
|
|||||||
Reference in New Issue
Block a user