blob: 3b04bcf4ad92d98ea4d3f90511c9ee09c7ea60e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
use std::fs::write;
use std::io::{Error, ErrorKind::Other, 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)
.ok_or_else(|| Error::new(Other, "Unable to parse Gemini Archive template"))?;
let rendered_template = parsed_template.render(context)?;
let location = target.join(FILENAME);
write(location, rendered_template)?;
},
None => {}
}
Ok(())
}
|