add alt text

This commit is contained in:
slonkazoid 2024-07-01 03:21:33 +03:00
parent cee11ba07a
commit a8a1dca444
Signed by: slonk
SSH key fingerprint: SHA256:tbZfJX4IOvZ0LGWOWu5Ijo8jfMPi78TU7x1VoEeCIjM
4 changed files with 17 additions and 9 deletions

View file

@ -1,7 +1,7 @@
--- ---
title: "README" title: README
description: "the README.md file of this project" description: the README.md file of this project
author: "slonkazoid" author: slonkazoid
created_at: 2024-04-18T04:15:26+03:00 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] finish writing this document
- [x] document config - [x] document config
- [ ] blog thumbnail and favicon - [ ] blog thumbnail and favicon
- [ ] alt text for post icon - [x] alt text for post icon
- [ ] extend syntect options - [ ] extend syntect options
- [ ] general cleanup of code - [ ] general cleanup of code
- [ ] better error reporting and error pages - [ ] better error reporting and error pages
@ -133,10 +133,11 @@ full example:
```md ```md
--- ---
title: "My first post" # title of the post title: My first post # title of the post
description: "The first post on this awesome blog!" # short description of the post description: The first post on this awesome blog! # short description of the post
author: "Blubber256" # author of the post author: Blubber256 # author of the post
icon: "/media/first-post/icon.png" # icon/thumbnail of post used in embeds 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 color: "#00aacc" # color of post, also used in embeds
created_at: 2024-04-18T04:15:26+03:00 # date of writing, this is highly 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), # recommended if you are on a system which doesnt have btime (like musl),

View file

@ -27,6 +27,7 @@ struct FrontMatter {
pub description: String, pub description: String,
pub author: String, pub author: String,
pub icon: Option<String>, pub icon: Option<String>,
pub icon_alt: Option<String>,
pub color: Option<String>, pub color: Option<String>,
pub created_at: Option<DateTime<Utc>>, pub created_at: Option<DateTime<Utc>>,
pub modified_at: Option<DateTime<Utc>>, pub modified_at: Option<DateTime<Utc>>,
@ -47,6 +48,7 @@ impl FrontMatter {
description: self.description, description: self.description,
author: self.author, author: self.author,
icon: self.icon, icon: self.icon,
icon_alt: self.icon_alt,
color: self.color, color: self.color,
created_at: self.created_at.or_else(|| created.map(|t| t.into())), created_at: self.created_at.or_else(|| created.map(|t| t.into())),
modified_at: self.modified_at.or_else(|| modified.map(|t| t.into())), modified_at: self.modified_at.or_else(|| modified.map(|t| t.into())),

View file

@ -17,7 +17,7 @@ pub struct PostMetadata {
pub description: String, pub description: String,
pub author: String, pub author: String,
pub icon: Option<String>, pub icon: Option<String>,
//pub icon_alt: Option<String>, pub icon_alt: Option<String>,
pub color: Option<String>, pub color: Option<String>,
pub created_at: Option<DateTime<Utc>>, pub created_at: Option<DateTime<Utc>>,
pub modified_at: Option<DateTime<Utc>>, pub modified_at: Option<DateTime<Utc>>,

View file

@ -18,6 +18,11 @@
<meta property="og:image" content="{{ url }}" /> <meta property="og:image" content="{{ url }}" />
<meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:image:src" content="{{ url }}" /> <meta property="twitter:image:src" content="{{ url }}" />
{% match meta.icon_alt %} {% when Some with (alt) %}
<meta property="og:image:alt" content="{{ alt }}" />
<meta property="twitter:image:alt" content="{{ alt }}" />
{% when None %} {% endmatch %}
<!-- prettier-br -->
{% when None %} {% endmatch %} {% when None %} {% endmatch %}
<!-- prettier is annoying --> <!-- prettier is annoying -->
{% match color %} {% when Some with (color) %} {% match color %} {% when Some with (color) %}