forge
Explore
Log in

Don't you dare go Hollow

personality

Clone
★ 0

0 watching0 forksRustGPL-3.0460.1 KiB4de8815Tahinli7 days ago22 commits

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