better post icon and color support

This commit is contained in:
slonkazoid 2024-07-01 02:34:13 +03:00
parent 602f57581a
commit 342a353b36
Signed by: slonk
SSH key fingerprint: SHA256:tbZfJX4IOvZ0LGWOWu5Ijo8jfMPi78TU7x1VoEeCIjM
4 changed files with 16 additions and 0 deletions

View file

@ -14,6 +14,7 @@ blazingly fast markdown blog software written in rust memory safe
- [x] RSS - [x] RSS
- [x] finish writing this document - [x] finish writing this document
- [x] document config - [x] document config
- [ ] 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

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 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>>,
#[serde(default)] #[serde(default)]
@ -46,6 +47,7 @@ impl FrontMatter {
description: self.description, description: self.description,
author: self.author, author: self.author,
icon: self.icon, icon: self.icon,
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())),
tags: self.tags.into_iter().collect(), tags: self.tags.into_iter().collect(),

View file

@ -17,6 +17,8 @@ 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 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>>,
pub tags: Vec<String>, pub tags: Vec<String>,

View file

@ -7,10 +7,21 @@
<meta name="author" content="{{ meta.author }}" /> <meta name="author" content="{{ meta.author }}" />
<meta name="keywords" content="{{ meta.tags|join(", ") }}" /> <meta name="keywords" content="{{ meta.tags|join(", ") }}" />
<meta name="description" content="{{ meta.title }}" /> <meta name="description" content="{{ meta.title }}" />
<!-- you know what I really love? platforms like discord
favoring twitter embeds over the open standard. to color
your embed or have large images, you have to do _this_. lmao -->
<meta property="og:title" content="{{ meta.title }}" /> <meta property="og:title" content="{{ meta.title }}" />
<meta property="twitter:title" content="{{ meta.title }}" />
<meta property="og:description" content="{{ meta.description }}" /> <meta property="og:description" content="{{ meta.description }}" />
<meta property="twitter:description" content="{{ meta.description }}" />
{% match meta.icon %} {% when Some with (url) %} {% match meta.icon %} {% when Some with (url) %}
<meta property="og:image" content="{{ url }}" /> <meta property="og:image" content="{{ url }}" />
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:image:src" content="{{ url }}" />
{% when None %} {% endmatch %}
<!-- prettier is annoying -->
{% match meta.color %} {% when Some with (color) %}
<meta name="theme-color" content="{{ color }}" />
{% when None %} {% endmatch %} {% when None %} {% endmatch %}
<title>{{ meta.title }}</title> <title>{{ meta.title }}</title>
<link rel="stylesheet" href="/static/style.css" /> <link rel="stylesheet" href="/static/style.css" />