diff --git a/src/lib.rs b/src/lib.rs index 2d73995..9aadbc9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,6 +72,15 @@ impl Preprocessor for LastChanged { } }); + let size = match ctx.config.get("output.html.recently-updated-size") { + Some(val) => match val { + toml::Value::Integer(i) => i, + _ => &5 + }, + None => &5, + }.to_owned(); + let size = usize::try_from(size).expect("Recently Updated size is not an usize"); + let mut vec: Vec<(LiteLink, NaiveDate)> = map .into_iter() .map(|e| (e.0, NaiveDate::from_str(&e.1).unwrap())) @@ -79,15 +88,16 @@ impl Preprocessor for LastChanged { // Sorting alphabetically and then by date, this means same date entries will be sorted alphabetically, otherwise the end result will be randomized when truncating vec.sort_by(|a, b| a.0.name.cmp(&b.0.name)); vec.sort_by(|a, b| b.1.cmp(&a.1)); - vec.truncate(5); + vec.truncate(size); let text: String = vec .into_iter() .map(|f| { format!( - "
  • {}
  • ", + "
  • {} - {}
  • ", f.0.path.unwrap().display(), - f.0.name + f.0.name, + f.1.to_string() ) }) .collect();