summaryrefslogtreecommitdiff
path: root/src/page.rs
diff options
context:
space:
mode:
authorradhitya <alif@radhitya.org>2026-06-20 17:52:48 +0700
committerradhitya <alif@radhitya.org>2026-06-20 17:52:48 +0700
commit829b4e3cf1e59732d0166cbd24d31c93c4095977 (patch)
tree9e7ca1936f872ce3d61079a3916de62c147d221b /src/page.rs
parent5b532e914bcad238af03a8916d961827bffc8058 (diff)
save output to public/
Diffstat (limited to 'src/page.rs')
-rw-r--r--src/page.rs10
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(())
+}