From 342a353b36fa1f9368409138682421f39d6e51c1 Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Mon, 1 Jul 2024 02:34:13 +0300 Subject: [PATCH] better post icon and color support --- README.md | 1 + src/post/markdown_posts.rs | 2 ++ src/post/mod.rs | 2 ++ templates/post.html | 11 +++++++++++ 4 files changed, 16 insertions(+) diff --git a/README.md b/README.md index dd87090..23e5088 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ blazingly fast markdown blog software written in rust memory safe - [x] RSS - [x] finish writing this document - [x] document config +- [ ] alt text for post icon - [ ] extend syntect options - [ ] general cleanup of code - [ ] better error reporting and error pages diff --git a/src/post/markdown_posts.rs b/src/post/markdown_posts.rs index e1ee1df..bb2809b 100644 --- a/src/post/markdown_posts.rs +++ b/src/post/markdown_posts.rs @@ -27,6 +27,7 @@ struct FrontMatter { pub description: String, pub author: String, pub icon: Option, + pub color: Option, pub created_at: Option>, pub modified_at: Option>, #[serde(default)] @@ -46,6 +47,7 @@ impl FrontMatter { description: self.description, author: self.author, icon: self.icon, + color: self.color, created_at: self.created_at.or_else(|| created.map(|t| t.into())), modified_at: self.modified_at.or_else(|| modified.map(|t| t.into())), tags: self.tags.into_iter().collect(), diff --git a/src/post/mod.rs b/src/post/mod.rs index 6dcb0b1..22e01df 100644 --- a/src/post/mod.rs +++ b/src/post/mod.rs @@ -17,6 +17,8 @@ pub struct PostMetadata { pub description: String, pub author: String, pub icon: Option, + //pub icon_alt: Option, + pub color: Option, pub created_at: Option>, pub modified_at: Option>, pub tags: Vec, diff --git a/templates/post.html b/templates/post.html index e577786..da6674a 100644 --- a/templates/post.html +++ b/templates/post.html @@ -7,10 +7,21 @@ + + + {% match meta.icon %} {% when Some with (url) %} + + + {% when None %} {% endmatch %} + + {% match meta.color %} {% when Some with (color) %} + {% when None %} {% endmatch %} {{ meta.title }}