From 33faf6fe70a091a35603bd112cf8aec3ae238f4f Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Sat, 20 May 2017 23:45:31 +0900 Subject: [PATCH] Make number RSS item configurable Fix #71 --- CHANGELOG.md | 1 + src/config.rs | 6 +++++- src/site.rs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4eb8fa90..99bdad82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fix missing serialized data for sections - Change the single item template context for categories/tags - Add a `get_url` global Tera function +- Add a config option to control how many articles to show in RSS feed ## 0.0.5 (2017-05-15) diff --git a/src/config.rs b/src/config.rs index f0aac90a..ec73d168 100644 --- a/src/config.rs +++ b/src/config.rs @@ -24,8 +24,10 @@ pub struct Config { pub description: Option, /// The language used in the site. Defaults to "en" pub language_code: Option, - /// Whether to generate RSS, defaults to false + /// Whether to generate RSS. Defaults to false pub generate_rss: Option, + /// The number of articles to include in the RSS feed. Defaults to unlimited + pub rss_limit: Option, /// Whether to generate tags and individual tag pages if some pages have them. Defaults to true pub generate_tags_pages: Option, /// Whether to generate categories and individual tag categories if some pages have them. Defaults to true @@ -59,6 +61,7 @@ impl Config { set_default!(config.language_code, "en".to_string()); set_default!(config.highlight_code, false); set_default!(config.generate_rss, false); + set_default!(config.rss_limit, ::max_value()); set_default!(config.generate_tags_pages, false); set_default!(config.generate_categories_pages, false); set_default!(config.insert_anchor_links, false); @@ -109,6 +112,7 @@ impl Default for Config { description: None, language_code: Some("en".to_string()), generate_rss: Some(false), + rss_limit: Some(10000), generate_tags_pages: Some(true), generate_categories_pages: Some(true), insert_anchor_links: Some(false), diff --git a/src/site.rs b/src/site.rs index 11b8a4c4..83cde51b 100644 --- a/src/site.rs +++ b/src/site.rs @@ -427,7 +427,7 @@ impl Site { let mut context = Context::new(); let pages = self.pages.values() .filter(|p| p.meta.date.is_some()) - .take(15) // limit to the last 15 elements + .take(self.config.rss_limit.unwrap()) // limit to the last n elements .cloned() .collect::>();