Ignore section with render=false when looking for path collisions

Closes #1656
This commit is contained in:
Vincent Prouillet 2022-05-06 22:44:14 +02:00
parent a958305e58
commit e0043a7351
2 changed files with 14 additions and 4 deletions

View File

@ -19,6 +19,7 @@ also specify classes on headers now
any pages related to that taxonomy any pages related to that taxonomy
- Serialize `transparent` field from front-matter of sections - 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 - 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) ## 0.15.3 (2022-01-23)

View File

@ -97,9 +97,11 @@ impl Library {
pub fn insert_section(&mut self, section: Section) { pub fn insert_section(&mut self, section: Section) {
let file_path = section.file.path.clone(); let file_path = section.file.path.clone();
let mut entries = vec![section.path.clone()]; if section.meta.render {
entries.extend(section.meta.aliases.to_vec()); let mut entries = vec![section.path.clone()];
self.insert_reverse_aliases(&file_path, entries); entries.extend(section.meta.aliases.to_vec());
self.insert_reverse_aliases(&file_path, entries);
}
self.sections.insert(file_path, section); self.sections.insert(file_path, section);
} }
@ -366,8 +368,15 @@ mod tests {
library.insert_section(section.clone()); library.insert_section(section.clone());
let mut section2 = Section { path: "world".to_owned(), ..Default::default() }; let mut section2 = Section { path: "world".to_owned(), ..Default::default() };
section2.file.path = PathBuf::from("bonjour.md"); 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()); 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(); let collisions = library.find_path_collisions();
assert_eq!(collisions.len(), 1); assert_eq!(collisions.len(), 1);