Skip to content

Commit

Permalink
Merge pull request #222 from contentstack/fix/DX-1371
Browse files Browse the repository at this point in the history
Fix/dx 1371
  • Loading branch information
netrajpatel authored Sep 27, 2024
2 parents 5c886a1 + fccb90c commit 4e3e3b1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/contentstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,21 @@ 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;
}
}
});
Expand Down

0 comments on commit 4e3e3b1

Please sign in to comment.