]> git.r.bdr.sh - rbdr/blog/blobdiff - src/archiver/gemini.rs
Generate and archive blog, allow publishing
[rbdr/blog] / src / archiver / gemini.rs
diff --git a/src/archiver/gemini.rs b/src/archiver/gemini.rs
new file mode 100644 (file)
index 0000000..8d56305
--- /dev/null
@@ -0,0 +1,19 @@
+use std::fs::write;
+use std::io::Result;
+use std::path::PathBuf;
+use crate::template::{find, parse, TemplateContext};
+
+const FILENAME: &str = "index.gmi";
+
+pub fn archive(_: &PathBuf, template_directory: &PathBuf, target: &PathBuf, context: &TemplateContext) -> Result<()> {
+    match find(template_directory, FILENAME) {
+        Some(template) => {
+            let parsed_template = parse(&template);
+            let rendered_template = parsed_template.render(context);
+            let location = target.join(FILENAME);
+            write(location, rendered_template)?;
+        },
+        None => {}
+    }
+    Ok(())
+}