diff --git a/src/main.rs b/src/main.rs
index fea5add..66f4847 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,22 +1,40 @@
use std::{
error::Error,
ffi::OsStr,
- fs::{read_dir, read_to_string, File},
+ fs::{read_dir, read_to_string, DirBuilder, File},
io::Write,
path::{Path, PathBuf},
};
const SRC_DIR: &str = "write";
const OUT_DIR: &str = "site";
+const CONTENT_MARKER: &str = "CONTENT HERE";
+
+const TEMPLATE_FILE: &str = "template.html";
+const DEFAULT_TEMPLATE: &[u8] = include_bytes!("../template.html");
+
type Result = core::result::Result<(), Box
\n"; - continue; } + if state == S::P { + html += "\n"; + } + state = S::Code; + html += "\n"; + continue; } if state == S::Code { @@ -98,12 +115,12 @@ fn convert_file(path: &Path) -> Result { } } - let template = read_to_string("template.html")?; - let html = template.replace("CONTENT HERE", &html); + let template = read_to_string(TEMPLATE_FILE)?; + let html = template.replacen(CONTENT_MARKER, &html, 1); - let mut file = File::create(out_path)?; + let mut file = File::create(&out_path)?; file.write_all(html.as_bytes())?; - + println!("built {}", out_path.display()); Ok(()) } diff --git a/template.html b/template.html new file mode 100644 index 0000000..67f63de --- /dev/null +++ b/template.html @@ -0,0 +1,14 @@ + + + + + + +TITLE HERE + + + + CONTENT HERE + + + \ No newline at end of file