From e77adc56fdc74525a8d778a18153812f8cbba1b2 Mon Sep 17 00:00:00 2001 From: Bob Date: Fri, 30 Aug 2019 21:44:57 +0800 Subject: [PATCH] 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 --- components/rebuild/src/lib.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/components/rebuild/src/lib.rs b/components/rebuild/src/lib.rs index 7e18034..02e6367 100644 --- a/components/rebuild/src/lib.rs +++ b/components/rebuild/src/lib.rs @@ -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");