Merge pull request #472 from chriskrycho/make-rss_limit-optional
Allow inclusion of all items in RSS feeds.
This commit is contained in:
commit
2c79eeb8be
|
@ -5,13 +5,13 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
use chrono::Utc;
|
||||
use globset::{Glob, GlobSet, GlobSetBuilder};
|
||||
use syntect::parsing::{SyntaxSet, SyntaxSetBuilder};
|
||||
use toml;
|
||||
use toml::Value as Toml;
|
||||
use syntect::parsing::{SyntaxSet, SyntaxSetBuilder};
|
||||
|
||||
use theme::Theme;
|
||||
use highlighting::THEME_SET;
|
||||
use errors::{Result, ResultExt};
|
||||
use highlighting::THEME_SET;
|
||||
use theme::Theme;
|
||||
|
||||
// We want a default base url for tests
|
||||
static DEFAULT_BASE_URL: &'static str = "http://a-website.com";
|
||||
|
@ -76,8 +76,8 @@ pub struct Config {
|
|||
|
||||
/// Whether to generate RSS. Defaults to false
|
||||
pub generate_rss: bool,
|
||||
/// The number of articles to include in the RSS feed. Defaults to 10_000
|
||||
pub rss_limit: usize,
|
||||
/// The number of articles to include in the RSS feed. Defaults to including all items.
|
||||
pub rss_limit: Option<usize>,
|
||||
|
||||
pub taxonomies: Vec<Taxonomy>,
|
||||
|
||||
|
@ -251,7 +251,7 @@ impl Default for Config {
|
|||
highlight_theme: "base16-ocean-dark".to_string(),
|
||||
default_language: "en".to_string(),
|
||||
generate_rss: false,
|
||||
rss_limit: 10_000,
|
||||
rss_limit: None,
|
||||
taxonomies: Vec::new(),
|
||||
compile_sass: false,
|
||||
check_external_links: false,
|
||||
|
|
|
@ -732,10 +732,11 @@ impl Site {
|
|||
pages.par_sort_unstable_by(sort_actual_pages_by_date);
|
||||
|
||||
context.insert("last_build_date", &pages[0].meta.date.clone().map(|d| d.to_string()));
|
||||
// limit to the last n elements
|
||||
// limit to the last n elements if the limit is set; otherwise use all.
|
||||
let num_entries = self.config.rss_limit.unwrap_or(pages.len());
|
||||
let p = pages
|
||||
.iter()
|
||||
.take(self.config.rss_limit)
|
||||
.take(num_entries)
|
||||
.map(|x| x.to_serialized_basic())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
|
|
@ -37,8 +37,9 @@ highlight_theme = "base16-ocean-dark"
|
|||
# Whether to generate a RSS feed automatically
|
||||
generate_rss = false
|
||||
|
||||
# The number of articles to include in the RSS feed
|
||||
rss_limit = 20
|
||||
# The number of articles to include in the RSS feed. Will include all items if
|
||||
# not set (the default).
|
||||
# rss_limit = 20
|
||||
|
||||
# The taxonomies to be rendered for that site and their configuration
|
||||
# Example:
|
||||
|
|
Loading…
Reference in a new issue