1
0
mirror of https://gitlab.com/Anson-Projects/zine.git synced 2025-07-27 08:41:25 +00:00

Add RSS feed

This commit is contained in:
2024-04-12 06:21:56 +00:00
parent 0924e73b95
commit e5ff6551e3
6 changed files with 195 additions and 13 deletions

View File

@@ -50,17 +50,28 @@ fn main() -> Result<(), Box<dyn Error>> {
entries.retain(|entry| entry.score.is_positive());
entries.sort();
let index = site_generator::generate_index(entries);
let output_path = Path::new("output/index.html");
let index = site_generator::generate_index(entries.clone());
let index_path = Path::new("output/index.html");
DirBuilder::new()
.recursive(true)
.create(output_path.parent().unwrap())
.create(index_path.parent().unwrap())
.unwrap();
match write(output_path, index.into_string()) {
Ok(_) => log::info!("Successfully wrote to {}", output_path.display()),
Err(e) => log::error!("Failed to write to {}: {}", output_path.display(), e),
match write(index_path, index.into_string()) {
Ok(_) => log::info!("Successfully wrote to {}", index_path.display()),
Err(e) => log::error!("Failed to write to {}: {}", index_path.display(), e),
}
let feed = site_generator::generate_rss(entries.clone());
let feed_path = Path::new("output/feed.xml");
DirBuilder::new()
.recursive(true)
.create(feed_path.parent().unwrap())
.unwrap();
match write(feed_path, feed) {
Ok(_) => log::info!("Successfully wrote to {}", feed_path.display()),
Err(e) => log::error!("Failed to write to {}: {}", feed_path.display(), e),
}
Ok(())