blob: 73c1630ba8b8d6ffcab929d100e7ce04a92b7207 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import { NavbarItem } from '../components/navbar';
import RemoveRoundedIcon from '@material-ui/icons/RemoveRounded';
import KeyboardArrowRightRoundedIcon from '@material-ui/icons/KeyboardArrowRightRounded';
import KeyboardArrowDownRoundedIcon from '@material-ui/icons/KeyboardArrowDownRounded';
interface chapter {
name: string;
sectionLink?: string;
children?: Array<chapter>;
}
class Chapter {
constructor(public chapters: Array<chapter>, public level: number) {}
render() {
console.log(this)
return <div>
{
this.chapters?.map(chapter => {
return <NavbarItem icon={<RemoveRoundedIcon/>} chapterIndent={this.level} title={chapter.name}>
{ new Chapter(chapter.children, this.level + 1).render() }
</NavbarItem>
})
}
</div>
}
}
export default function Chapters(props: {
chapters: Array<chapter>;
}) {
return new Chapter(props.chapters, 0).render();
}
|