Skip to content

Commit

Permalink
perf(v2): convert Promise style to async/await style
Browse files Browse the repository at this point in the history
for consistency
  • Loading branch information
moonrailgun committed Jun 15, 2020
1 parent 41d13d5 commit b7df851
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/docusaurus-plugin-content-blog/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,16 +441,18 @@ export default function pluginContentBlog(
const feedTypes = getFeedTypes(options.feedOptions?.type);

await Promise.all(
feedTypes.map((feedType) => {
feedTypes.map(async (feedType) => {
const feedPath = path.join(
outDir,
options.routeBasePath,
`${feedType}.xml`,
);
const feedContent = feedType === 'rss' ? feed.rss2() : feed.atom1();
return fs.outputFile(feedPath, feedContent).catch((err) => {
try {
await fs.outputFile(feedPath, feedContent);
} catch (err) {
throw new Error(`Generating ${feedType} feed failed: ${err}`);
});
}
}),
);
},
Expand Down

0 comments on commit b7df851

Please sign in to comment.