change to written_At

This commit is contained in:
slonkazoid 2024-12-29 23:12:04 +03:00
parent 01bc3ae4ae
commit e6f2c6c697
Signed by: slonk
SSH key fingerprint: SHA256:tbZfJX4IOvZ0LGWOWu5Ijo8jfMPi78TU7x1VoEeCIjM
5 changed files with 12 additions and 10 deletions

View file

@ -2,7 +2,7 @@
title: README
description: the README.md file of this project
author: slonkazoid
created_at: 2024-04-18T04:15:26+03:00
written_at: 2024-04-18T04:15:26+03:00
---
# bingus-blog
@ -83,7 +83,7 @@ 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
written_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),
# because this is fetched from file stats by default
#modified_at: ... # see above. this is also fetched from the filesystem
@ -94,7 +94,7 @@ tags: # tags, or keywords, used in meta and also in the ui
only first 3 fields are required. if it can't find the other 2 fields, it will
get them from filesystem metadata. if you are on musl and you omit the
`created_at` field, it will just not show up
`written_at` field, it will just not show up
the dates must follow the [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339)
standard. examples of valid and invalid dates:

View file

@ -210,7 +210,7 @@ async fn rss(
})
.collect::<Vec<Category>>(),
)
.pub_date(metadata.created_at.map(|date| date.to_rfc2822()))
.pub_date(metadata.written_at.map(|date| date.to_rfc2822()))
.content(content.to_string())
.link(
config

View file

@ -33,7 +33,8 @@ struct BlagMetadata {
pub icon: Option<Arc<str>>,
pub icon_alt: Option<Arc<str>>,
pub color: Option<Arc<str>>,
pub created_at: Option<DateTime<Utc>>,
#[serde(alias = "created_at")]
pub written_at: Option<DateTime<Utc>>,
pub modified_at: Option<DateTime<Utc>>,
#[serde(default)]
pub tags: BTreeSet<Arc<str>>,
@ -52,7 +53,7 @@ impl BlagMetadata {
icon: self.icon,
icon_alt: self.icon_alt,
color: self.color,
created_at: self.created_at,
written_at: self.written_at,
modified_at: self.modified_at,
tags: self.tags.into_iter().collect(),
},

View file

@ -37,7 +37,8 @@ struct FrontMatter {
pub icon: Option<Arc<str>>,
pub icon_alt: Option<Arc<str>>,
pub color: Option<Arc<str>>,
pub created_at: Option<DateTime<Utc>>,
#[serde(alias = "created_at")]
pub written_at: Option<DateTime<Utc>>,
pub modified_at: Option<DateTime<Utc>>,
#[serde(default)]
pub tags: BTreeSet<Arc<str>>,
@ -58,7 +59,7 @@ impl FrontMatter {
icon: self.icon,
icon_alt: self.icon_alt,
color: self.color,
created_at: self.created_at.or_else(|| created.map(|t| t.into())),
written_at: self.written_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(),
}

View file

@ -26,7 +26,7 @@ pub struct PostMetadata {
pub icon: Option<Arc<str>>,
pub icon_alt: Option<Arc<str>>,
pub color: Option<Arc<str>>,
pub created_at: Option<DateTime<Utc>>,
pub written_at: Option<DateTime<Utc>>,
pub modified_at: Option<DateTime<Utc>>,
pub tags: Vec<Arc<str>>,
}
@ -121,7 +121,7 @@ pub trait PostManager {
.await?;
// we still want some semblance of order if created_at is None so sort by mtime as well
posts.sort_unstable_by_key(|metadata| metadata.modified_at.unwrap_or_default());
posts.sort_by_key(|metadata| metadata.created_at.unwrap_or_default());
posts.sort_by_key(|metadata| metadata.written_at.unwrap_or_default());
posts.reverse();
if let Some(n) = n {
posts.truncate(n);