| 1 | use topcoat::{ |
| 2 | Result, |
| 3 | context::Cx, |
| 4 | view::{View, component, view}, |
| 5 | }; |
| 6 | |
| 7 | use crate::content::Block; |
| 8 | |
| 9 | #[component] |
| 10 | pub async fn blocks(cx: &Cx, items: &[Block]) -> Result<impl View> { |
| 11 | Ok(view! { |
| 12 | <div class="blocks"> |
| 13 | for block in items { |
| 14 | match block { |
| 15 | Block::Heading(text) => <h2>(text)</h2>, |
| 16 | Block::Paragraph(text) => <p>(text)</p>, |
| 17 | Block::Lines(lines) => <p> |
| 18 | for (i, line) in lines.iter().enumerate() { |
| 19 | if i > 0 { |
| 20 | <br> |
| 21 | } |
| 22 | (line) |
| 23 | } |
| 24 | </p>, |
| 25 | } |
| 26 | } |
| 27 | </div> |
| 28 | }) |
| 29 | } |