diff options
| author | Xe Iaso <me@christine.website> | 2022-11-25 19:01:10 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-25 19:01:10 -0500 |
| commit | cc933b31fd23bb06e95bf41f848a1c99353d44ae (patch) | |
| tree | af8288dbd4db2ad886d6b326bffb1c9d5b568de3 /src/post | |
| parent | 551e0384c923ff3ee98cfddf7e3eb42c6dbb2941 (diff) | |
| download | xesite-cc933b31fd23bb06e95bf41f848a1c99353d44ae.tar.xz xesite-cc933b31fd23bb06e95bf41f848a1c99353d44ae.zip | |
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 <me@christine.website>
* fix nix builds
Signed-off-by: Xe Iaso <me@christine.website>
* fix dhall build
Signed-off-by: Xe Iaso <me@christine.website>
* fix non-flakes build
Signed-off-by: Xe Iaso <me@christine.website>
* make new mastodon share button
Signed-off-by: Xe Iaso <me@christine.website>
* remove the rest of the ructe templates that I can remove
Signed-off-by: Xe Iaso <me@christine.website>
* refactor blogposts to its own file
Signed-off-by: Xe Iaso <me@christine.website>
* move resume to be generated by nix
Signed-off-by: Xe Iaso <me@christine.website>
* write article
Signed-off-by: Xe Iaso <me@christine.website>
* blog/site-update-v3: hero image
Signed-off-by: Xe Iaso <me@christine.website>
* add site update series tag to site updates
Signed-off-by: Xe Iaso <me@christine.website>
Signed-off-by: Xe <me@christine.website>
Signed-off-by: Xe Iaso <me@christine.website>
Diffstat (limited to 'src/post')
| -rw-r--r-- | src/post/mod.rs | 24 | ||||
| -rw-r--r-- | src/post/schemaorg.rs | 14 |
2 files changed, 34 insertions, 4 deletions
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<schemaorg::Article> 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<xe_jsonfeed::Item> 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<mi::Client>) -> 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<FixedOffset> = - DateTime::<Utc>::from_utc(NaiveDateTime::new(date, NaiveTime::from_hms(0, 0, 0)), Utc) - .with_timezone(&Utc) - .into(); + let date: DateTime<FixedOffset> = DateTime::<Utc>::from_utc( + NaiveDateTime::new(date, NaiveTime::from_hms_opt(0, 0, 0).unwrap()), + Utc, + ) + .with_timezone(&Utc) + .into(); let mentions: Vec<mi::WebMention> = 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, +} |
