From a135acf943ba0fc442dca69f43339921728b1ed4 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Thu, 22 Jun 2023 15:35:18 +0100 Subject: implement blog tag filtering --- src/main.rs | 46 ++++++++++++++++++------------- src/posts/mod.rs | 55 +++++++++++++++++++++++++++----------- src/posts/note.rs | 8 +++++- static/style.css | 4 +-- templates/base.html.tera | 2 +- templates/blogpost-panel.html.tera | 2 +- templates/filtertags.html.tera | 4 +-- 7 files changed, 80 insertions(+), 41 deletions(-) diff --git a/src/main.rs b/src/main.rs index c08c2e1..40f546d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ mod scrobbles; mod skweets; use std::borrow::Cow; +use std::collections::HashSet; use rocket::fs::{relative, FileServer}; use rocket::http::Status; @@ -47,24 +48,6 @@ 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