Subject:

How to fix cobalt.rs's feed showing only excerpts


Date: Message-Id: https://www.5snb.club/posts/2020/how-to-fix-cobalts-feed/

By default, the content in the RSS feed is the post description, then the excerpt (if it exists), and then finally the actual page content.

IMO, this is a bad default. If people want to read the first few paragraphs in a RSS reader but switch to my website to read the rest, they can do that. But I don’t want to force them to do that.

In any case, I’ve included a patch against cobalt.rs’s current master branch to just always use the page content, but still let you use the excerpt for other things, like page contents. And if you’ve not used my site’s RSS feed because it didn’t show full contents, you can use it now.

Formatting’s still a bit weird on my reader, but it’s usable.

diff --git a/src/document.rs b/src/document.rs
index 85a3ec5..e1a74f1 100644
--- a/src/document.rs
+++ b/src/document.rs
@@ -274,23 +274,9 @@ impl Document {
     }
 
     fn description_to_str(&self) -> Option<String> {
-        self.front
-            .description
-            .clone()
-            .or_else(|| {
-                self.attributes.get("excerpt").and_then(|excerpt| {
-                    if excerpt.is_nil() {
-                        None
-                    } else {
-                        Some(excerpt.render().to_string())
-                    }
-                })
-            })
-            .or_else(|| {
-                self.attributes
-                    .get("content")
-                    .map(|s| s.render().to_string())
-            })
+        self.attributes
+            .get("content")
+            .map(|s| s.render().to_string())
     }
 
     /// Renders liquid templates into HTML in the context of current document.