From 14fef52913c92e106a4ca8d47fe3035485524df6 Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Thu, 25 May 2023 10:04:14 -0400 Subject: [PATCH] fix: nested media field media_folder evaluation --- packages/core/src/lib/util/media.util.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/core/src/lib/util/media.util.ts b/packages/core/src/lib/util/media.util.ts index 0e5155a4..51a2dda6 100644 --- a/packages/core/src/lib/util/media.util.ts +++ b/packages/core/src/lib/util/media.util.ts @@ -174,6 +174,7 @@ function traverseFields( | ListField | ObjectField | undefined; + if (matchedField && isMediaField(folderKey, matchedField)) { return folderFormatter( matchedField[folderKey] ? matchedField[folderKey]! : `{{${folderKey}}}`, @@ -185,12 +186,7 @@ function traverseFields( ); } - for (const f of fields) { - const childField: Field = { ...f }; - if (isMediaField(folderKey, childField) && !childField[folderKey]) { - // add identity template if doesn't exist - childField[folderKey] = `{{${folderKey}}}`; - } + for (const childField of fields) { const folder = folderFormatter( isMediaField(folderKey, childField) ? childField[folderKey] ?? '' : '', entryMap, @@ -206,7 +202,7 @@ function traverseFields( config, collection, entryMap, - childField, + field, childField.fields, folder, ); @@ -216,7 +212,7 @@ function traverseFields( config, collection, entryMap, - childField, + field, childField.types, folder, );