openaire-graph-docs/sidebar-utils.js

18 lines
469 B
JavaScript
Raw Permalink Normal View History

2022-09-21 19:35:12 +02:00
// filter out specific items from the sidebar
function filterItems(items, itemsToFilter) {
// filter out items of categories
let result = items.map((item) => {
if (item.type === 'category') {
return {...item, items: filterItems(item.items, itemsToFilter)};
}
return item;
});
// filter out items in current level
return result.filter( item => !itemsToFilter.includes(item.id) );
}
2022-09-21 19:35:12 +02:00
module.exports = {
2022-09-21 19:35:12 +02:00
filterItems
};