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/atom.rs | |
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/atom.rs')
-rw-r--r-- | src/atom.rs | 18 |
1 files changed, 13 insertions, 5 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(), |