From e0043a7351fa92a801d3e99f07d8a5b0fef738de Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Fri, 6 May 2022 22:44:14 +0200 Subject: [PATCH] Ignore section with render=false when looking for path collisions Closes #1656 --- CHANGELOG.md | 1 + components/content/src/library.rs | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cda93ab..5151df51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ also specify classes on headers now any pages related to that taxonomy - Serialize `transparent` field from front-matter of sections - Use Zola Tera instance for markdown filter: this means you have access to the same Tera functions as in shortcodes +- Ignore sections with `render=false` when looking for path collisions ## 0.15.3 (2022-01-23) diff --git a/components/content/src/library.rs b/components/content/src/library.rs index bae36477..67875e5e 100644 --- a/components/content/src/library.rs +++ b/components/content/src/library.rs @@ -97,9 +97,11 @@ impl Library { pub fn insert_section(&mut self, section: Section) { let file_path = section.file.path.clone(); - let mut entries = vec![section.path.clone()]; - entries.extend(section.meta.aliases.to_vec()); - self.insert_reverse_aliases(&file_path, entries); + if section.meta.render { + let mut entries = vec![section.path.clone()]; + entries.extend(section.meta.aliases.to_vec()); + self.insert_reverse_aliases(&file_path, entries); + } self.sections.insert(file_path, section); } @@ -366,8 +368,15 @@ mod tests { library.insert_section(section.clone()); let mut section2 = Section { path: "world".to_owned(), ..Default::default() }; section2.file.path = PathBuf::from("bonjour.md"); - section2.meta.aliases = vec!["hello".to_owned()]; + section2.meta.aliases = vec!["hello".to_owned(), "hola".to_owned()]; library.insert_section(section2.clone()); + // Sections with render=false do not collide with anything + // https://github.com/getzola/zola/issues/1656 + let mut section3 = Section { path: "world2".to_owned(), ..Default::default() }; + section3.meta.render = false; + section3.file.path = PathBuf::from("bonjour2.md"); + section3.meta.aliases = vec!["hola".to_owned()]; + library.insert_section(section3); let collisions = library.find_path_collisions(); assert_eq!(collisions.len(), 1);