valkyrie_docgen/items/container/
toc.rs1use super::*;
2
3#[derive(Clone, Debug)]
4pub struct TableOfContentsArray(pub Vec<TableOfContentsItem>);
5
6#[derive(Clone, Debug)]
7pub struct TableOfContentsItem(pub Html, pub Vec<Html>);
8
9impl Renderable for TableOfContentsArray {
10 fn render(&self) -> Html {
11 let items: Html = self.0.iter().map(|e| e.render()).collect();
12 html! {
13 <nav class="toc">
14 <div class="catalog-title">{"Table of Contents"}</div>
15 <div class="catalog-body"><ul class="catalog-list">{items}</ul></div>
16 </nav>
17 }
18 }
19}
20
21impl Renderable for TableOfContentsItem {
22 fn render(&self) -> Html {
23 let title = self.0.clone();
24 if self.1.is_empty() {
25 return html! {<li class="item d1">{title}</li>};
26 }
27 let items: Html = self.1.clone().into_iter().map(|e| html! {<li class="item d2">{e}</li>}).collect();
28 html! {<li class="item d1">{title}<ul class="sub-list">{items}</ul></li>}
29 }
30}