diff options
author | cel 🌸 <cel@blos.sm> | 2024-01-31 17:52:44 +0000 |
---|---|---|
committer | cel 🌸 <cel@blos.sm> | 2024-01-31 17:52:44 +0000 |
commit | 4100e7db9fc88cbc9a6e9bbe508097f971761269 (patch) | |
tree | 1a7de64fa25f02812cab5404dd6f45e7e4de62f8 /src | |
parent | e2bf8728c086d4a42ff1ec2b8f916dc07377f399 (diff) | |
download | blossom-4100e7db9fc88cbc9a6e9bbe508097f971761269.tar.gz blossom-4100e7db9fc88cbc9a6e9bbe508097f971761269.tar.bz2 blossom-4100e7db9fc88cbc9a6e9bbe508097f971761269.zip |
change Post updated_at to an option
Diffstat (limited to 'src')
-rw-r--r-- | src/atom.rs | 18 | ||||
-rw-r--r-- | src/posts.rs | 2 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/atom.rs b/src/atom.rs index 4410edb..a64a6aa 100644 --- a/src/atom.rs +++ b/src/atom.rs @@ -68,11 +68,19 @@ pub async fn atom<P: Post + Clone>(ctx: Context, entries: Vec<P>) -> Feed { .clone() .into_iter() .fold(DateTime::<Utc>::MIN_UTC, |acc, entry| { - let updated_at = entry.updated_at().to_owned(); - if updated_at > acc { - updated_at + if let Some(updated_at) = entry.updated_at() { + if *updated_at > acc { + *updated_at + } else { + acc + } } else { - acc + let published_at = entry.published_at(); + if *published_at > acc { + *published_at + } else { + acc + } } }) .into(), @@ -118,7 +126,7 @@ pub async fn atom<P: Post + Clone>(ctx: Context, entries: Vec<P>) -> Feed { r#type: TextType::Text, }, id: entry.link(), - updated: entry.updated_at().to_owned().into(), + updated: (*entry.updated_at().unwrap_or_else(|| entry.published_at())).into(), authors: authors.clone(), categories, contributors: authors.clone(), diff --git a/src/posts.rs b/src/posts.rs index 415f743..a8e9f90 100644 --- a/src/posts.rs +++ b/src/posts.rs @@ -13,7 +13,7 @@ pub trait Post { fn id(&self) -> &str; fn subject(&self) -> Option<&str>; fn published_at(&self) -> &DateTime<Utc>; - fn updated_at(&self) -> &DateTime<Utc>; + fn updated_at(&self) -> Option<&DateTime<Utc>>; fn tags(&self) -> &Vec<String>; fn lang(&self) -> &str; fn post_type(&self) -> PostType; |