Skip to content

Commit 0d8bd53

Browse files
authored
Promise.all for getLinkData() (#25863)
1 parent af9dbd3 commit 0d8bd53

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

lib/get-link-data.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,14 @@ export default async (
1717
return await processLink(rawLinks, context, option)
1818
}
1919

20-
const links = []
21-
22-
for (const link of rawLinks) {
23-
const linkObj = await processLink(link, context, option)
24-
if (!linkObj) {
25-
continue
26-
} else {
27-
links.push(linkObj)
28-
}
29-
}
20+
const links = (
21+
await Promise.all(rawLinks.map((link) => processLink(link, context, option)))
22+
).filter(Boolean)
3023

3124
return links
3225
}
3326

34-
const processLink = async (link, context, option) => {
27+
async function processLink(link, context, option) {
3528
const opts = { textOnly: true, encodeEntities: true }
3629
// Parse the link in case it includes Liquid conditionals
3730
const linkPath = await renderContent(link.href || link, context, opts)

0 commit comments

Comments
 (0)