(doc: &'static crate::docs::DocPage)
| 118 | }} |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | #[component] |
| 123 | fn BookArticle(doc: &'static crate::docs::DocPage) -> impl IntoView { |
| 124 | let chapters = book_pages() |
| 125 | .into_iter() |
| 126 | .filter(|page| page.slug != "index") |
| 127 | .collect::<Vec<_>>(); |
| 128 | let pos = chapters.iter().position(|page| page.slug == doc.slug); |
| 129 | let prev = pos |
| 130 | .and_then(|idx| idx.checked_sub(1)) |
| 131 | .and_then(|idx| chapters.get(idx).copied()); |
| 132 | let next = pos.and_then(|idx| chapters.get(idx + 1).copied()); |
| 133 | |
| 134 | view! { |
| 135 | <Seo info=doc_seo(doc, doc.route_path.as_str()) /> |
| 136 | <PageFrame eyebrow="Book" title=doc.title.as_str()> |
| 137 | <div class="doc-layout"> |
| 138 | <aside class="doc-filter"> |
| 139 | <h2>"Chapters"</h2> |
| 140 | <a href="/book"><span>"Start"</span><small>"0"</small></a> |
| 141 | {chapters.into_iter().enumerate().map(|(idx, chapter)| view! { |
| 142 | <a href=chapter.route_path.as_str()> |
| 143 | <span>{chapter.title.as_str()}</span> |
| 144 | <small>{idx + 1}</small> |
| 145 | </a> |
| 146 | }).collect_view()} |
| 147 | </aside> |
| 148 | <div class="doc-results"> |
| 149 | <div class="doc-page"> |
| 150 | <article class="article" inner_html=doc.html.as_str()></article> |
| 151 | <aside class="toc"> |
| 152 | <strong>"On page"</strong> |
| 153 | {doc.headings.iter().filter(|h| (2..=3).contains(&h.level)).map(|h| view! { |
| 154 | <a href=format!("#{}", h.id)>{h.text.as_str()}</a> |
| 155 | }).collect_view()} |
| 156 | </aside> |
| 157 | </div> |
| 158 | <nav class="page-actions"> |
| 159 | {prev.map(|page| view! { |
| 160 | <a class="btn ghost" href=page.route_path.as_str()>{format!("Previous: {}", page.title)}</a> |
| 161 | })} |
| 162 | {next.map(|page| view! { |
| 163 | <a class="btn primary" href=page.route_path.as_str()>{format!("Next: {}", page.title)}</a> |
| 164 | })} |
| 165 | </nav> |
| 166 | </div> |
| 167 | </div> |
| 168 | </PageFrame> |
| 169 | } |
| 170 | } |
nothing calls this directly
no test coverage detected