aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/atom.rs18
-rw-r--r--src/posts.rs2
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;