Files
supabase/apps/docs/internals/helpers.mjs
2022-12-15 15:51:37 -03:30

16 lines
407 B
JavaScript

export function flattenSections(sections) {
var a = []
for (var i = 0; i < sections.length; i++) {
if (sections[i].id) {
// only push a section that has an id
// these are reserved for sidebar subtitles
a.push(sections[i])
}
if (sections[i].items) {
// if there are subitems, loop through
a = a.concat(flattenSections(sections[i].items))
}
}
return a
}