From 05b8bb4ac62f18e5278292fcb5db4b62e31999f7 Mon Sep 17 00:00:00 2001 From: Magnus Hovland Hoff Date: Sat, 20 Oct 2018 17:19:13 +0200 Subject: [PATCH] Ensure root output directory exists explicitly. Aliases that have no directory nesting sneakily avoid the code path that ensures the directories exist --- components/site/src/lib.rs | 1 + components/site/tests/site.rs | 4 ++-- test_site/content/posts/top-level-alias.md | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test_site/content/posts/top-level-alias.md diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index f2a6f0e..4ed1d28 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -565,6 +565,7 @@ impl Site { } pub fn render_aliases(&self) -> Result<()> { + ensure_directory_exists(&self.output_path)?; for (_, page) in self.library.pages() { for alias in &page.meta.aliases { let mut output_path = self.output_path.to_path_buf(); diff --git a/components/site/tests/site.rs b/components/site/tests/site.rs index 4d05c45..afbc245 100644 --- a/components/site/tests/site.rs +++ b/components/site/tests/site.rs @@ -19,7 +19,7 @@ fn can_parse_site() { site.load().unwrap(); // Correct number of pages (sections are pages too) - assert_eq!(site.library.pages().len(), 15); + assert_eq!(site.library.pages().len(), 16); let posts_path = path.join("content").join("posts"); // Make sure the page with a url doesn't have any sections @@ -41,7 +41,7 @@ fn can_parse_site() { let posts_section = site.library.get_section(&posts_path.join("_index.md")).unwrap(); assert_eq!(posts_section.subsections.len(), 1); - assert_eq!(posts_section.pages.len(), 7); + assert_eq!(posts_section.pages.len(), 8); assert_eq!(posts_section.ancestors, vec![*site.library.get_section_key(&index_section.file.path).unwrap()]); // Make sure we remove all the pwd + content from the sections diff --git a/test_site/content/posts/top-level-alias.md b/test_site/content/posts/top-level-alias.md new file mode 100644 index 0000000..a40b1d5 --- /dev/null +++ b/test_site/content/posts/top-level-alias.md @@ -0,0 +1,8 @@ ++++ +title = "Top level alias" +description = "" +date = 2017-01-01 +aliases = ["top-level.html"] ++++ + +Simple page