(sidebar, ...remove)
| 1 | function removeItems(sidebar, ...remove) { |
| 2 | const result = []; |
| 3 | for (let item of sidebar) { |
| 4 | if (typeof item === 'string') |
| 5 | { |
| 6 | if (!remove.includes(item)) result.push({ |
| 7 | type: 'ref', id: item |
| 8 | }); |
| 9 | } |
| 10 | else { |
| 11 | if (!remove.includes(item.label)) { |
| 12 | const {items, ...rest} = item; |
| 13 | const keepItems = removeItems(items, ...remove); |
| 14 | if (keepItems?.length > 0 || rest.link) result.push({...rest, items: keepItems}); |
| 15 | } |
| 16 | } |
| 17 | } |
| 18 | return result; |
| 19 | } |
| 20 | |
| 21 | const fullSidebar = [ |
| 22 |