From 5f2a48905634e7874946425057dc904dcb6c7d16 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Wed, 21 Jun 2023 23:46:20 +0100 Subject: implement blog --- src/main.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index dd2bd34..c08c2e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,6 +47,36 @@ async fn home(clients: &State) -> Template { ) } +#[get("/blog")] +async fn blog() -> Template { + let mut blogposts = posts::get_blogposts().await.unwrap_or_default(); + let tags = posts::get_tags(&blogposts); + for blogpost in &mut blogposts { + blogpost.render().await; + } + let reverse = "reverse".to_owned(); + Template::render( + "blog", + context! { + reverse, + blogposts, + tags, + }, + ) +} + +#[get("/blog/")] +async fn blogpost(blogpost: &str) -> Result