Skip to content

Commit

Permalink
Ignore section with render=false when looking for path collisions
Browse files Browse the repository at this point in the history
Closes #1656
  • Loading branch information
Keats committed May 6, 2022
1 parent a958305 commit e0043a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
17 changes: 13 additions & 4 deletions components/content/src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e0043a7

Please sign in to comment.