diff --git a/src/routes/blog.rs b/src/routes/blog.rs index a1e31f1..8a2890a 100644 --- a/src/routes/blog.rs +++ b/src/routes/blog.rs @@ -54,11 +54,12 @@ static ENTRIES: LazyLock> = p { "Tags: " (tags.join(", ")) + "." } } p { - "Also, if you are a dinosaur that enjoys good technogoly, check out my" + "Also, if you are a dinosaur that enjoys good technology, check out my " a href="/feed" { "RSS Feed" } "." } @@ -80,9 +81,9 @@ pub async fn index_handler() -> Markup { &html! { h1 { "Blog Articles" } p { - "Are you old? Then you might want to check out the super cool " + "Are you old? Then you might want to check out my super cool hand-generated " a href="/feed" { "RSS Feed" } - "." + " too!" } ul { @@ -113,7 +114,7 @@ static FEED: LazyLock = LazyLock::new(|| { let items = ENTRIES.iter().map(|(path, (metadata, body))| { ItemBuilder::default() - .link(Some(format!("{url}{path}"))) + .link(Some(format!("{url}blog/{path}"))) .title(Some(metadata.title.clone())) .description(metadata.description.clone()) .author(Some("contact@rgbcu.be".to_string())) diff --git a/src/routes/blog/test.md b/src/routes/blog/test.md new file mode 100644 index 0000000..5188a63 --- /dev/null +++ b/src/routes/blog/test.md @@ -0,0 +1,14 @@ +--- +title: Testing Blog & RSS +description: Just me testing the blog and RSS feed. + Nothing to see here. +date: 19/01/2024 +tags: + - foo + - bar + - baz +--- + +# Test + +That's it. That's the whole blog entry. diff --git a/src/routes/markdown.rs b/src/routes/markdown.rs index 0e67609..fc2ae66 100644 --- a/src/routes/markdown.rs +++ b/src/routes/markdown.rs @@ -12,10 +12,42 @@ use serde::Deserialize; use crate::markdown; +mod ddmmyyyy { + use chrono::{ + DateTime, + NaiveDate, + Utc, + }; + use serde::{ + self, + Deserialize, + Deserializer, + }; + + pub fn deserialize<'de, D>(deserializer: D) -> Result>, D::Error> + where + D: Deserializer<'de>, + { + match Option::::deserialize(deserializer)? { + None => Ok(None), + Some(s) => { + Ok(Some(DateTime::::from_naive_utc_and_offset( + NaiveDate::parse_from_str(&s, "%d/%m/%Y") + .map_err(serde::de::Error::custom)? + .and_hms_opt(0, 0, 0) + .unwrap(), + Utc, + ))) + }, + } + } +} + #[derive(Deserialize, Debug)] pub struct Metadata { pub title: String, pub description: Option, + #[serde(default, with = "ddmmyyyy")] pub date: Option>, pub tags: Option>, }