Browse Source

Merge pull request #472 from chriskrycho/make-rss_limit-optional

Allow inclusion of all items in RSS feeds.
index-subcmd
Vincent Prouillet GitHub 6 years ago
parent
commit
2c79eeb8be
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 10 deletions
  1. +6
    -6
      components/config/src/config.rs
  2. +3
    -2
      components/site/src/lib.rs
  3. +3
    -2
      docs/content/documentation/getting-started/configuration.md

+ 6
- 6
components/config/src/config.rs View File

@@ -5,13 +5,13 @@ use std::path::{Path, PathBuf};


use chrono::Utc; use chrono::Utc;
use globset::{Glob, GlobSet, GlobSetBuilder}; use globset::{Glob, GlobSet, GlobSetBuilder};
use syntect::parsing::{SyntaxSet, SyntaxSetBuilder};
use toml; use toml;
use toml::Value as Toml; use toml::Value as Toml;
use syntect::parsing::{SyntaxSet, SyntaxSetBuilder};


use theme::Theme;
use highlighting::THEME_SET;
use errors::{Result, ResultExt}; use errors::{Result, ResultExt};
use highlighting::THEME_SET;
use theme::Theme;


// We want a default base url for tests // We want a default base url for tests
static DEFAULT_BASE_URL: &'static str = "http://a-website.com"; static DEFAULT_BASE_URL: &'static str = "http://a-website.com";
@@ -76,8 +76,8 @@ pub struct Config {


/// Whether to generate RSS. Defaults to false /// Whether to generate RSS. Defaults to false
pub generate_rss: bool, 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>, pub taxonomies: Vec<Taxonomy>,


@@ -251,7 +251,7 @@ impl Default for Config {
highlight_theme: "base16-ocean-dark".to_string(), highlight_theme: "base16-ocean-dark".to_string(),
default_language: "en".to_string(), default_language: "en".to_string(),
generate_rss: false, generate_rss: false,
rss_limit: 10_000,
rss_limit: None,
taxonomies: Vec::new(), taxonomies: Vec::new(),
compile_sass: false, compile_sass: false,
check_external_links: false, check_external_links: false,


+ 3
- 2
components/site/src/lib.rs View File

@@ -732,10 +732,11 @@ impl Site {
pages.par_sort_unstable_by(sort_actual_pages_by_date); 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())); 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 let p = pages
.iter() .iter()
.take(self.config.rss_limit)
.take(num_entries)
.map(|x| x.to_serialized_basic()) .map(|x| x.to_serialized_basic())
.collect::<Vec<_>>(); .collect::<Vec<_>>();




+ 3
- 2
docs/content/documentation/getting-started/configuration.md View File

@@ -37,8 +37,9 @@ highlight_theme = "base16-ocean-dark"
# Whether to generate a RSS feed automatically # Whether to generate a RSS feed automatically
generate_rss = false 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 # The taxonomies to be rendered for that site and their configuration
# Example: # Example:


Loading…
Cancel
Save