From fd40a5d31a210a7ad69dd3f7d35909cf0e4e350f Mon Sep 17 00:00:00 2001 From: zyl Date: Tue, 14 Jan 2025 10:51:28 -0800 Subject: [PATCH] create parent directories when creating a page in subdirectories --- src/main.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7dd14d5..f93091c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -256,11 +256,8 @@ fn main() -> eyre::Result<()> { title, template, } => { - let page_path = cli - .site - .join(webdog::PAGES_PATH) - .join(&id) - .with_extension("md"); + let page_path = cli.site.join(webdog::PAGES_PATH).join(&id).with_extension("md"); + let dir = page_path.parent().expect("should never fail"); if page_path.exists() { eprintln!("page already exists!"); return Ok(()); @@ -273,7 +270,7 @@ fn main() -> eyre::Result<()> { ..Default::default() }), }; - std::fs::create_dir_all(page_path.parent().expect("should never fail"))?; + std::fs::create_dir_all(dir)?; std::fs::write(&page_path, fm.format()?)?; println!("Page created! Edit at {:?}.", page_path);