| 1 | pub mod slug; |
| 2 | |
| 3 | use topcoat::{ |
| 4 | Result, |
| 5 | context::Cx, |
| 6 | router::{href, page}, |
| 7 | view::{View, component, view}, |
| 8 | }; |
| 9 | |
| 10 | use crate::{app::Title, content::projects::Project}; |
| 11 | |
| 12 | pub fn detail_url(cx: &Cx, project: Project) -> String { |
| 13 | href!(slug::detail, slug: project.slug()).resolve(cx) |
| 14 | } |
| 15 | |
| 16 | #[component] |
| 17 | pub async fn project_row(cx: &Cx, project: Project) -> Result<impl View> { |
| 18 | Ok(view! { |
| 19 | <a class="row" href=(detail_url(cx, project))> |
| 20 | <span class="row-key">(project.slug())</span> |
| 21 | <span>(project.name()) <span class="row-sub">" · " (project.summary())</span></span> |
| 22 | </a> |
| 23 | }) |
| 24 | } |
| 25 | |
| 26 | #[page(with(Title(|_| "Projects · tahinli".to_owned())))] |
| 27 | pub async fn index(cx: &Cx) -> Result<impl View> { |
| 28 | Ok(view! { |
| 29 | <h2 class="label">"Projects"</h2> |
| 30 | for project in Project::ALL { |
| 31 | project_row(project: project) |
| 32 | } |
| 33 | }) |
| 34 | } |