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-23 16:19:32 +02:00
|
|
|
}
|
2022-09-21 19:35:12 +02:00
|
|
|
|
2022-09-23 16:19:32 +02:00
|
|
|
module.exports = {
|
2022-09-21 19:35:12 +02:00
|
|
|
filterItems
|
2022-09-23 16:19:32 +02:00
|
|
|
};
|