forge
Explore
Log in

Don't you dare go Hollow

personality

Clone
★ 0

0 watching0 forksRustGPL-3.0460.1 KiB4de8815Tahinli7 days ago22 commits

slug.rs38 lines, 1.0 KiBHistoryRawDownload
1use topcoat::{
2 Result,
3 context::Cx,
4 router::{error::RouterErrorExt, href, module_param, page},
5 view::{View, view},
6};
7
8use crate::{
9 app::{Title, blocks::blocks},
10 content::posts::Post,
11};
12
13module_param!(pub slug);
14
15fn title(cx: &Cx) -> String {
16 match Post::from_slug(slug(cx)) {
17 Some(post) => format!("{} · tahinli", post.title()),
18 None => String::from("tahinli"),
19 }
20}
21
22#[page(with(Title(title)))]
23pub async fn detail(cx: &Cx) -> Result<impl View> {
24 let post = Post::from_slug(slug(cx)).ok_or_not_found()?;
25 let meta = match post.date() {
26 Some(date) => format!("{} · {} · Ahmet Kaan Gümüş", post.kind().label(), date),
27 None => format!("{} · Ahmet Kaan Gümüş", post.kind().label()),
28 };
29
30 Ok(view! {
31 <article class="article">
32 <a class="back" href=(href!(super::index))>"← posts"</a>
33 <h1>(post.title())</h1>
34 <span class="meta">(meta)</span>
35 blocks(items: post.body())
36 </article>
37 })
38}