Skip to content

Commit

Permalink
refactor: reduce -> filter
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Mar 15, 2020
1 parent 6114694 commit 9e3717b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions docs/scripts/buildApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,18 @@ async function annotateComponentDefinition(component, api) {
);
}

const demos = api.pagesMarkdown.reduce((accumulator, page) => {
if (page.components.includes(api.name)) {
accumulator.push(page);
}

return accumulator;
}, []);
const demos = uniqBy(
api.pagesMarkdown.filter(page => {
return page.components.includes(api.name);
}, []),
page => page.pathname,
);

const jsdoc = `/**
* ${api.description}
*
* Demos:
* - ${uniqBy(demos, page => page.pathname)
* - ${demos
.map(page => `{@link https://material-ui.com${page.pathname} ${pageToTitle(page)}}`)
.join('\n * - ')}
*
Expand Down

0 comments on commit 9e3717b

Please sign in to comment.