Use reduce to handle doc items sequentially

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
This commit is contained in:
Josh-Cena 2021-06-21 09:37:35 +08:00
parent 1e8b06d0a4
commit c7525d463b
No known key found for this signature in database
GPG key ID: C37145B818BDB68F

View file

@ -268,10 +268,10 @@ export const DefaultSidebarItemsGenerator: SidebarItemsGenerator = async functio
}
// async process made sequential on purpose! order matters
for (const doc of docs) {
// eslint-disable-next-line no-await-in-loop
await handleDocItem(doc);
}
await docs.reduce(
(p, doc) => p.then(() => handleDocItem(doc)),
Promise.resolve(),
);
return sidebarItems;
}