diff --git a/src/app/components/SectionDropdown.tsx b/src/app/components/SectionDropdown.tsx index 83c430d..e6ff1a6 100644 --- a/src/app/components/SectionDropdown.tsx +++ b/src/app/components/SectionDropdown.tsx @@ -1,39 +1,8 @@ -import { Fragment } from 'react'; import { useSectionContext } from '../context/section'; import { Doc, DocsStructure } from '../types/types'; import { toKebabCase } from '../utils/stringUtils'; import styles from './SectionDropdown.module.css'; -function SectionDropdownOption({ doc }: { doc: Doc }) { - return ( - - {doc.copy && doc.example && ( - - )} - {doc.children && doc.children.length > 0 && ( - - {doc.children.map(child => ( - - ))} - - )} - - ); -} - export default function SectionDropdown({ version, }: { @@ -45,6 +14,22 @@ export default function SectionDropdown({ location.hash = e.target.value; }; + const getAllDocs = (docs: Doc[]) => { + let result: Doc[] = []; + + docs.forEach(doc => { + result.push(doc); + + if (doc.children && doc.children.length > 0) { + result = result.concat(getAllDocs(doc.children)); + } + }); + + return result; + }; + + const docs = getAllDocs(version.docs); + return (