diff --git a/components/content/benches/all.rs b/components/content/benches/all.rs index cb80fdb..5a90943 100644 --- a/components/content/benches/all.rs +++ b/components/content/benches/all.rs @@ -11,7 +11,7 @@ use std::collections::HashMap; use config::Config; use tera::Tera; use front_matter::{SortBy, InsertAnchor}; -use content::{Page, sort_pages, populate_previous_and_next_pages}; +use content::{Page, sort_pages, populate_siblings}; fn create_pages(number: usize, sort_by: SortBy) -> Vec { @@ -128,17 +128,17 @@ fn bench_sorting_order(b: &mut test::Bencher) { } #[bench] -fn bench_populate_previous_and_next_pages(b: &mut test::Bencher) { +fn bench_populate_siblings(b: &mut test::Bencher) { let pages = create_pages(250, SortBy::Order); let (sorted_pages, _) = sort_pages(pages, SortBy::Order); - b.iter(|| populate_previous_and_next_pages(&sorted_pages.clone())); + b.iter(|| populate_siblings(&sorted_pages.clone())); } #[bench] fn bench_page_render_html(b: &mut test::Bencher) { let pages = create_pages(10, SortBy::Order); let (mut sorted_pages, _) = sort_pages(pages, SortBy::Order); - sorted_pages = populate_previous_and_next_pages(&sorted_pages); + sorted_pages = populate_siblings(&sorted_pages); let config = Config::default(); let mut tera = Tera::default(); diff --git a/components/content/src/lib.rs b/components/content/src/lib.rs index 5d111c4..11bfcc8 100644 --- a/components/content/src/lib.rs +++ b/components/content/src/lib.rs @@ -26,4 +26,4 @@ mod sorting; pub use file_info::FileInfo; pub use page::Page; pub use section::Section; -pub use sorting::{sort_pages, populate_previous_and_next_pages}; +pub use sorting::{sort_pages, populate_siblings}; diff --git a/components/content/src/sorting.rs b/components/content/src/sorting.rs index 592d844..775c67b 100644 --- a/components/content/src/sorting.rs +++ b/components/content/src/sorting.rs @@ -53,7 +53,7 @@ pub fn sort_pages(pages: Vec, sort_by: SortBy) -> (Vec, Vec) { /// Horribly inefficient way to set previous and next on each pages that skips drafts /// So many clones -pub fn populate_previous_and_next_pages(input: &[Page], sort_by: SortBy) -> Vec { +pub fn populate_siblings(input: &[Page], sort_by: SortBy) -> Vec { let mut res = Vec::with_capacity(input.len()); // The input is already sorted @@ -140,7 +140,7 @@ pub fn populate_previous_and_next_pages(input: &[Page], sort_by: SortBy) -> Vec< mod tests { use front_matter::{PageFrontMatter, SortBy}; use page::Page; - use super::{sort_pages, populate_previous_and_next_pages}; + use super::{sort_pages, populate_siblings}; fn create_page_with_date(date: &str) -> Page { let mut front_matter = PageFrontMatter::default(); @@ -208,13 +208,13 @@ mod tests { } #[test] - fn can_populate_previous_and_next_pages() { + fn can_populate_siblings() { let input = vec![ create_page_with_weight(1), create_page_with_weight(2), create_page_with_weight(3), ]; - let pages = populate_previous_and_next_pages(&input, SortBy::Weight); + let pages = populate_siblings(&input, SortBy::Weight); assert!(pages[0].clone().lighter.is_none()); assert!(pages[0].clone().heavier.is_some()); diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index 85d1095..2e9a4aa 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -36,7 +36,7 @@ use config::{Config, get_config}; use utils::fs::{create_file, copy_directory, create_directory, ensure_directory_exists}; use utils::templates::{render_template, rewrite_theme_paths}; use utils::net::get_available_port; -use content::{Page, Section, populate_previous_and_next_pages, sort_pages}; +use content::{Page, Section, populate_siblings, sort_pages}; use templates::{GUTENBERG_TERA, global_fns, render_redirect_template}; use front_matter::{SortBy, InsertAnchor}; use taxonomies::{Taxonomy, find_taxonomies}; @@ -401,7 +401,7 @@ impl Site { } let pages = mem::replace(&mut section.pages, vec![]); let (sorted_pages, cannot_be_sorted_pages) = sort_pages(pages, section.meta.sort_by); - section.pages = populate_previous_and_next_pages(&sorted_pages, section.meta.sort_by); + section.pages = populate_siblings(&sorted_pages, section.meta.sort_by); section.ignored_pages = cannot_be_sorted_pages; } }