mdf-blog/src/main.rs
2026-03-26 13:20:05 +01:00

27 lines
891 B
Rust

use std::{env::args, io};
use markdown::to_html;
use rss::{Channel, Item, ChannelBuilder, ItemBuilder};
fn main() -> io::Result<()> {
// takes directory of markdown files as only argument, outputs
// html output into stdout (TODO make )
let mut channel = Channel::default();
channel.title = "MDF blog huge".to_string();
channel.link = "rakarake.xyz".to_string();
channel.description = "morbius text wow".to_string();
channel.items = std::env::args().skip(1).map(|f| {
let contents = std::fs::read_to_string(f.clone())?;
let html = to_html(&contents);
// TODO get the title from the document, read other metadata
Ok(ItemBuilder::default()
.title(f)
.description(html)
.build()
)
}).collect::<Result<Vec<Item>, io::Error>>()?;
println!("{}", channel.to_string());
Ok(())
}