diff options
Diffstat (limited to 'src/page.rs')
| -rw-r--r-- | src/page.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/page.rs b/src/page.rs index c81887d..2ee065a 100644 --- a/src/page.rs +++ b/src/page.rs @@ -63,7 +63,7 @@ pub fn parse_page(source_path: &PathBuf) -> anyhow::Result<Page> { let slug = meta.title.to_lowercase().replace(' ', "-"); let output_path = PathBuf::from("public").join(&slug).join("index.html"); - + save_file(&output_path, &html)?; Ok (Page { meta, source_path: source_path.clone(), @@ -85,3 +85,11 @@ pub fn render_markdown(input: &str) -> String { html::push_html(&mut out, parser); out } + +pub fn save_file(output_path: &PathBuf, content: &str) -> anyhow::Result<()> { + if let Some(public) = output_path.parent() { + fs::create_dir_all(public)?; + } + fs::write(output_path, content)?; + Ok(()) +} |
