From cc933b31fd23bb06e95bf41f848a1c99353d44ae Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Fri, 25 Nov 2022 19:01:10 -0500 Subject: Start version 3 (#573) * Start version 3 * Change version to 3.0.0 in Cargo.toml * Add metadata for series * Change types for signal boosts * Add start of LaTeX resume generation at Nix time * Add start of proper author tagging for posts in JSONFeed and ldjson * Convert templates to use Maud * Add start of dynamic resume generation from dhall * Make patrons page embed thumbnails TODO: * [ ] Remove the rest of the old templates * [ ] Bring in Xeact for the share on mastodon button * [ ] Site update post Signed-off-by: Xe * fix nix builds Signed-off-by: Xe Iaso * fix dhall build Signed-off-by: Xe Iaso * fix non-flakes build Signed-off-by: Xe Iaso * make new mastodon share button Signed-off-by: Xe Iaso * remove the rest of the ructe templates that I can remove Signed-off-by: Xe Iaso * refactor blogposts to its own file Signed-off-by: Xe Iaso * move resume to be generated by nix Signed-off-by: Xe Iaso * write article Signed-off-by: Xe Iaso * blog/site-update-v3: hero image Signed-off-by: Xe Iaso * add site update series tag to site updates Signed-off-by: Xe Iaso Signed-off-by: Xe Signed-off-by: Xe Iaso --- src/post/mod.rs | 24 ++++++++++++++++++++---- src/post/schemaorg.rs | 14 ++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 src/post/schemaorg.rs (limited to 'src/post') diff --git a/src/post/mod.rs b/src/post/mod.rs index 8ed99bf..65c859e 100644 --- a/src/post/mod.rs +++ b/src/post/mod.rs @@ -6,6 +6,7 @@ use std::{borrow::Borrow, cmp::Ordering, path::PathBuf}; use tokio::fs; pub mod frontmatter; +pub mod schemaorg; #[derive(Eq, PartialEq, Debug, Clone, Serialize, Deserialize)] pub struct Post { @@ -26,6 +27,19 @@ pub struct NewPost { pub link: String, } +impl Into for &Post { + fn into(self) -> schemaorg::Article { + schemaorg::Article { + context: "https://schema.org".to_string(), + r#type: "Article".to_string(), + headline: self.front_matter.title.clone(), + image: "https://xeiaso.net/static/img/avatar.png".to_string(), + url: format!("https://xeiaso.net/{}", self.link), + date_published: self.date.format("%Y-%m-%d").to_string(), + } + } +} + impl Into for Post { fn into(self) -> xe_jsonfeed::Item { let mut result = xe_jsonfeed::Item::builder() @@ -99,10 +113,12 @@ async fn read_post(dir: &str, fname: PathBuf, cli: &Option) -> Resul let link = format!("{}/{}", dir, fname.file_stem().unwrap().to_str().unwrap()); let body_html = xesite_markdown::render(&body) .wrap_err_with(|| format!("can't parse markdown for {:?}", fname))?; - let date: DateTime = - DateTime::::from_utc(NaiveDateTime::new(date, NaiveTime::from_hms(0, 0, 0)), Utc) - .with_timezone(&Utc) - .into(); + let date: DateTime = DateTime::::from_utc( + NaiveDateTime::new(date, NaiveTime::from_hms_opt(0, 0, 0).unwrap()), + Utc, + ) + .with_timezone(&Utc) + .into(); let mentions: Vec = match cli { Some(cli) => cli diff --git a/src/post/schemaorg.rs b/src/post/schemaorg.rs new file mode 100644 index 0000000..18c238a --- /dev/null +++ b/src/post/schemaorg.rs @@ -0,0 +1,14 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Eq, PartialEq, Debug, Clone, Serialize, Deserialize)] +pub struct Article { + #[serde(rename = "@context")] + pub context: String, + #[serde(rename = "@type")] + pub r#type: String, + pub headline: String, + pub image: String, + pub url: String, + #[serde(rename = "datePublished")] + pub date_published: String, +} -- cgit v1.2.3