use topcoat::{ Result, context::Cx, router::{error::RouterErrorExt, href, module_param, page}, view::{View, view}, }; use crate::{ app::{Title, blocks::blocks}, content::posts::Post, }; module_param!(pub slug); fn title(cx: &Cx) -> String { match Post::from_slug(slug(cx)) { Some(post) => format!("{} · tahinli", post.title()), None => String::from("tahinli"), } } #[page(with(Title(title)))] pub async fn detail(cx: &Cx) -> Result { let post = Post::from_slug(slug(cx)).ok_or_not_found()?; let meta = match post.date() { Some(date) => format!("{} · {} · Ahmet Kaan Gümüş", post.kind().label(), date), None => format!("{} · Ahmet Kaan Gümüş", post.kind().label()), }; Ok(view! {
"← posts"

(post.title())

(meta) blocks(items: post.body())
}) }