Within this tree structure, I need to extract items with a release version of 0.0.1 to use in building my navigation based on that specific release number.
{
title: '',
items: [
{
title: '',
path: '',
release: '0.0.1'
},
{
title: '',
path: '',
release: '0.0.2'
}
]
},
{
title: '',
items: [
{
title: '',
items: [
{
title: '',
path: '',
release: '0.0.2'
},
{
title: '',
path: '',
items: [
{
title: '',
path: '',
release: '0.0.1'
},
{
title: '',
path: '',
release: '0.0.2'
}
]
}
]
}
]
}
It's crucial to maintain the same tree structure for consistency when constructing the navigation menu.
{
title: '',
items: [
{
title: '',
path: '',
release: '0.0.1'
},
]
},
{
title: '',
items: [
{
title: '',
items: [
{
title: '',
path: '',
items: [
{
title: '',
path: '',
release: '0.0.1'
},
]
}
]
}
]
}
I have succeeded in filtering two levels of nested trees as shown above, but encountered challenges when dealing with deeper levels of nesting within items
.
const menuToggle = (condition) => (menus) => menus
.map(menu => ({
...menu,
items: menu.items.filter(item => condition(item))
}))
.filter(menu => !isEmpty(menu.items));