mirror of
https://github.com/zyllian/webdog.git
synced 2025-01-18 03:32:21 -08:00
create parent directories when creating a page in subdirectories
This commit is contained in:
parent
9608925572
commit
fd40a5d31a
1 changed files with 3 additions and 6 deletions
|
@ -256,11 +256,8 @@ fn main() -> eyre::Result<()> {
|
||||||
title,
|
title,
|
||||||
template,
|
template,
|
||||||
} => {
|
} => {
|
||||||
let page_path = cli
|
let page_path = cli.site.join(webdog::PAGES_PATH).join(&id).with_extension("md");
|
||||||
.site
|
let dir = page_path.parent().expect("should never fail");
|
||||||
.join(webdog::PAGES_PATH)
|
|
||||||
.join(&id)
|
|
||||||
.with_extension("md");
|
|
||||||
if page_path.exists() {
|
if page_path.exists() {
|
||||||
eprintln!("page already exists!");
|
eprintln!("page already exists!");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -273,7 +270,7 @@ fn main() -> eyre::Result<()> {
|
||||||
..Default::default()
|
..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()?)?;
|
std::fs::write(&page_path, fm.format()?)?;
|
||||||
|
|
||||||
println!("Page created! Edit at {:?}.", page_path);
|
println!("Page created! Edit at {:?}.", page_path);
|
||||||
|
|
Loading…
Add table
Reference in a new issue