From a8a1dca444aa72a198633852591f0098b3f3f3c7 Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Mon, 1 Jul 2024 03:21:33 +0300 Subject: [PATCH] add alt text --- README.md | 17 +++++++++-------- src/post/markdown_posts.rs | 2 ++ src/post/mod.rs | 2 +- templates/post.html | 5 +++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 66d5427..4fface4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ --- -title: "README" -description: "the README.md file of this project" -author: "slonkazoid" +title: README +description: the README.md file of this project +author: slonkazoid created_at: 2024-04-18T04:15:26+03:00 --- @@ -15,7 +15,7 @@ blazingly fast markdown blog software written in rust memory safe - [x] finish writing this document - [x] document config - [ ] blog thumbnail and favicon -- [ ] alt text for post icon +- [x] alt text for post icon - [ ] extend syntect options - [ ] general cleanup of code - [ ] better error reporting and error pages @@ -133,10 +133,11 @@ full example: ```md --- -title: "My first post" # title of the post -description: "The first post on this awesome blog!" # short description of the post -author: "Blubber256" # author of the post -icon: "/media/first-post/icon.png" # icon/thumbnail of post used in embeds +title: My first post # title of the post +description: The first post on this awesome blog! # short description of the post +author: Blubber256 # author of the post +icon: /media/first-post/icon.png # icon/thumbnail of post used in embeds +icon_alt: Picture of a computer running DOOM color: "#00aacc" # color of post, also used in embeds created_at: 2024-04-18T04:15:26+03:00 # date of writing, this is highly # recommended if you are on a system which doesnt have btime (like musl), diff --git a/src/post/markdown_posts.rs b/src/post/markdown_posts.rs index bb2809b..e4d0287 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 icon_alt: Option, pub color: Option, pub created_at: Option>, pub modified_at: Option>, @@ -47,6 +48,7 @@ impl FrontMatter { description: self.description, author: self.author, icon: self.icon, + icon_alt: self.icon_alt, 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())), diff --git a/src/post/mod.rs b/src/post/mod.rs index 22e01df..202d78b 100644 --- a/src/post/mod.rs +++ b/src/post/mod.rs @@ -17,7 +17,7 @@ pub struct PostMetadata { pub description: String, pub author: String, pub icon: Option, - //pub icon_alt: Option, + pub icon_alt: Option, pub color: Option, pub created_at: Option>, pub modified_at: Option>, diff --git a/templates/post.html b/templates/post.html index cd05916..8abfe66 100644 --- a/templates/post.html +++ b/templates/post.html @@ -18,6 +18,11 @@ + {% match meta.icon_alt %} {% when Some with (alt) %} + + + {% when None %} {% endmatch %} + {% when None %} {% endmatch %} {% match color %} {% when Some with (color) %}