Browse Source

Fix the issue when checking the changes for multiple language section index file (#787)

* Fix the issue when checking the changes of multiple language section
index-subcmd
Bob Vincent Prouillet 5 years ago
parent
commit
e77adc56fd
1 changed files with 20 additions and 1 deletions
  1. +20
    -1
      components/rebuild/src/lib.rs

+ 20
- 1
components/rebuild/src/lib.rs View File

@@ -323,9 +323,28 @@ pub fn after_content_rename(site: &mut Site, old: &Path, new: &Path) -> Result<(
Ok(())
}

fn is_section(path: &str, languages_codes: &[&str]) -> bool {
if path == "_index.md" {
return true;
}

for language_code in languages_codes {
let lang_section_string = format!("_index.{}.md", language_code);
if path == lang_section_string {
return true;
}
}

return false;
}

/// What happens when a section or a page is created/edited
pub fn after_content_change(site: &mut Site, path: &Path) -> Result<()> {
let is_section = path.file_name().unwrap() == "_index.md";
let is_section = {
let languages_codes = site.config.languages_codes();
is_section(path.file_name().unwrap().to_str().unwrap(), &languages_codes)
};

let is_md = path.extension().unwrap() == "md";
let index = path.parent().unwrap().join("index.md");



Loading…
Cancel
Save