Make number RSS item configurable

Fix #71
This commit is contained in:
Vincent Prouillet 2017-05-20 23:45:31 +09:00
parent d2b6cbde2f
commit 33faf6fe70
3 changed files with 7 additions and 2 deletions

View file

@ -5,6 +5,7 @@
- Fix missing serialized data for sections - Fix missing serialized data for sections
- Change the single item template context for categories/tags - Change the single item template context for categories/tags
- Add a `get_url` global Tera function - 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) ## 0.0.5 (2017-05-15)

View file

@ -24,8 +24,10 @@ pub struct Config {
pub description: Option<String>, pub description: Option<String>,
/// The language used in the site. Defaults to "en" /// The language used in the site. Defaults to "en"
pub language_code: Option<String>, pub language_code: Option<String>,
/// Whether to generate RSS, defaults to false /// Whether to generate RSS. Defaults to false
pub generate_rss: Option<bool>, pub generate_rss: Option<bool>,
/// The number of articles to include in the RSS feed. Defaults to unlimited
pub rss_limit: Option<usize>,
/// Whether to generate tags and individual tag pages if some pages have them. Defaults to true /// Whether to generate tags and individual tag pages if some pages have them. Defaults to true
pub generate_tags_pages: Option<bool>, pub generate_tags_pages: Option<bool>,
/// Whether to generate categories and individual tag categories if some pages have them. Defaults to true /// 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.language_code, "en".to_string());
set_default!(config.highlight_code, false); set_default!(config.highlight_code, false);
set_default!(config.generate_rss, false); set_default!(config.generate_rss, false);
set_default!(config.rss_limit, <usize>::max_value());
set_default!(config.generate_tags_pages, false); set_default!(config.generate_tags_pages, false);
set_default!(config.generate_categories_pages, false); set_default!(config.generate_categories_pages, false);
set_default!(config.insert_anchor_links, false); set_default!(config.insert_anchor_links, false);
@ -109,6 +112,7 @@ impl Default for Config {
description: None, description: None,
language_code: Some("en".to_string()), language_code: Some("en".to_string()),
generate_rss: Some(false), generate_rss: Some(false),
rss_limit: Some(10000),
generate_tags_pages: Some(true), generate_tags_pages: Some(true),
generate_categories_pages: Some(true), generate_categories_pages: Some(true),
insert_anchor_links: Some(false), insert_anchor_links: Some(false),

View file

@ -427,7 +427,7 @@ impl Site {
let mut context = Context::new(); let mut context = Context::new();
let pages = self.pages.values() let pages = self.pages.values()
.filter(|p| p.meta.date.is_some()) .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() .cloned()
.collect::<Vec<Page>>(); .collect::<Vec<Page>>();