+ fn handle(&self, source: &PathBuf, destination: &PathBuf, file: &File, layout: &String) {
+ let gemini_contents = read_to_string(&file.path).unwrap();
+
+ // Front matter extraction
+ let lines: Vec<&str> = gemini_contents.split("\n").collect();
+ let mut lines_found = 0;
+ let mut title = "";
+ let mut description = "";
+ for line in lines[..2].iter() {
+ if self.is_title(&line) {
+ title = self.get_title(&line).trim();
+ lines_found = lines_found + 1;
+ continue;
+ }
+ if self.is_description(&line) {
+ description = self.get_description(&line).trim();
+ lines_found = lines_found + 1;
+ continue;
+ }
+ }
+
+ let gemini_source = lines[lines_found..].join("\n");
+ let content_html = parse(&gemini_source[..]);
+
+ let generated_html = layout
+ .replace("{{ title }}", title)
+ .replace("{{ description }}", description)
+ .replace("{{ content }}", &content_html[..]);
+
+
+ let relative_path = file.path.strip_prefix(&source).unwrap();
+ let mut complete_destination = destination.join(relative_path);
+ complete_destination.set_extension("html");
+ let destination_parent = complete_destination.parent().unwrap();
+ create_dir_all(destination_parent).unwrap();
+
+ let mut destination_file = IOFile::create(&complete_destination).unwrap();
+ destination_file.write_all(generated_html.as_bytes()).unwrap();