]>
Commit | Line | Data |
---|---|---|
b17907fa | 1 | use crate::template::{find, parse, Context}; |
6352ebb0 | 2 | use std::fs::write; |
50f53dc4 | 3 | use std::io::{Error, ErrorKind::Other, Result}; |
d7fef30a | 4 | use std::path::Path; |
6352ebb0 RBR |
5 | |
6 | const FILENAME: &str = "index.gmi"; | |
7 | ||
d7fef30a RBR |
8 | pub fn archive( |
9 | _: &Path, | |
10 | template_directory: &Path, | |
11 | target: &Path, | |
b17907fa | 12 | context: &Context, |
d7fef30a RBR |
13 | ) -> Result<()> { |
14 | if let Some(template) = find(template_directory, FILENAME) { | |
15 | let parsed_template = parse(&template) | |
16 | .ok_or_else(|| Error::new(Other, "Unable to parse Gemini Archive template"))?; | |
17 | let rendered_template = parsed_template.render(context)?; | |
18 | let location = target.join(FILENAME); | |
19 | write(location, rendered_template)?; | |
6352ebb0 RBR |
20 | } |
21 | Ok(()) | |
22 | } |