export function flattenSections(sections: any[]): any[] { let a: any[] = [] for (let 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 }