From 9cf40b195bc806ad36af3f3284e4084f7347c7de Mon Sep 17 00:00:00 2001 From: Vikram Kalta Date: Tue, 24 Sep 2024 23:53:20 +0100 Subject: [PATCH 1/2] fix: fixed updateAssetUrl issue --- src/core/contentstack.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/core/contentstack.js b/src/core/contentstack.js index bcffa3a3..bb10c1db 100755 --- a/src/core/contentstack.js +++ b/src/core/contentstack.js @@ -51,10 +51,27 @@ class Contentstack { if (item._content_type_uid == 'sys_assets' && item.filename) { - const correspondingAsset = entry[key].children.find(child => child.attrs['asset-uid'] === item.uid); + let correspondingAsset; + const x = (children) => { + for (let i = 0; i < children.length; i++) { + if (children[i].children && children[i].children.length) { + x(children[i].children); + } + if (children[i].attrs && children[i].attrs['asset-uid'] === item.uid) { + correspondingAsset = children[i].attrs; + return; + } + } + } + x(entry[key].children); if (correspondingAsset) { - correspondingAsset.attrs['asset-link'] = item.url; + correspondingAsset['href'] = item.url; } + + // const correspondingAsset = entry[key].children.find(child => child.attrs['asset-uid'] === item.uid); + // if (correspondingAsset) { + // correspondingAsset.attrs['asset-link'] = item.url; + // } } }); } From fccb90cb09b168853d7291988239c05d25f4f670 Mon Sep 17 00:00:00 2001 From: Vikram Kalta Date: Thu, 26 Sep 2024 08:41:08 +0100 Subject: [PATCH 2/2] fix: removed comments --- src/core/contentstack.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/core/contentstack.js b/src/core/contentstack.js index bb10c1db..abfd157a 100755 --- a/src/core/contentstack.js +++ b/src/core/contentstack.js @@ -67,11 +67,6 @@ class Contentstack { if (correspondingAsset) { correspondingAsset['href'] = item.url; } - - // const correspondingAsset = entry[key].children.find(child => child.attrs['asset-uid'] === item.uid); - // if (correspondingAsset) { - // correspondingAsset.attrs['asset-link'] = item.url; - // } } }); }