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
This commit is contained in:
parent
fb89f94516
commit
e77adc56fd
|
@ -323,9 +323,28 @@ pub fn after_content_rename(site: &mut Site, old: &Path, new: &Path) -> Result<(
|
||||||
Ok(())
|
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
|
/// What happens when a section or a page is created/edited
|
||||||
pub fn after_content_change(site: &mut Site, path: &Path) -> Result<()> {
|
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 is_md = path.extension().unwrap() == "md";
|
||||||
let index = path.parent().unwrap().join("index.md");
|
let index = path.parent().unwrap().join("index.md");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue