diff --git a/components/rebuild/src/lib.rs b/components/rebuild/src/lib.rs index 48fbe6f..7b6d3a1 100644 --- a/components/rebuild/src/lib.rs +++ b/components/rebuild/src/lib.rs @@ -262,6 +262,13 @@ pub fn after_content_rename(site: &mut Site, old: &Path, new: &Path) -> Result<( return site.build(); } + // We ignore renames on non-markdown files for now + if let Some(ext) = new_path.extension() { + if ext != "md" { + return Ok(()); + } + } + // Renaming a file to _index.md, let the section editing do something and hope for the best if new_path.file_name().unwrap() == "_index.md" { // We aren't entirely sure where the original thing was so just try to delete whatever was diff --git a/components/rebuild/tests/rebuild.rs b/components/rebuild/tests/rebuild.rs index 275273e..4d743ab 100644 --- a/components/rebuild/tests/rebuild.rs +++ b/components/rebuild/tests/rebuild.rs @@ -223,3 +223,14 @@ fn can_rebuild_after_renaming_section_folder() { assert!(file_contains!(site_path, "public/new-posts/simple/index.html", "simple")); } + +#[test] +fn can_rebuild_after_renaming_non_md_asset_in_colocated_folder() { + let tmp_dir = tempdir().expect("create temp dir"); + let (site_path, mut site) = load_and_build_site!(tmp_dir); + let (old_path, new_path) = rename!(site_path, "content/posts/with-assets/zola.png", "gutenberg.png"); + + // Testing that we don't try to load some images as markdown or something + let res = after_content_rename(&mut site, &old_path, &new_path); + assert!(res.is_ok()); +} diff --git a/test_site/content/posts/with-assets/index.md b/test_site/content/posts/with-assets/index.md index b182f9a..383ad8a 100644 --- a/test_site/content/posts/with-assets/index.md +++ b/test_site/content/posts/with-assets/index.md @@ -4,4 +4,4 @@ description = "hey there" date = 2015-03-01 +++ -Hello world +Hello world [here](with.js) diff --git a/test_site/content/posts/with-assets/zola.png b/test_site/content/posts/with-assets/zola.png new file mode 100644 index 0000000..1eb41f9 Binary files /dev/null and b/test_site/content/posts/with-assets/zola.png differ