mirror of
https://github.com/RGBCube/Site
synced 2025-08-01 13:37:49 +00:00
Fix dates and typos
This commit is contained in:
parent
d26f4856c5
commit
870a7a69e9
3 changed files with 51 additions and 4 deletions
|
@ -54,11 +54,12 @@ static ENTRIES: LazyLock<IndexMap<&'static str, (&'static Metadata, Markup)>> =
|
||||||
p {
|
p {
|
||||||
"Tags: "
|
"Tags: "
|
||||||
(tags.join(", "))
|
(tags.join(", "))
|
||||||
|
"."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
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" }
|
a href="/feed" { "RSS Feed" }
|
||||||
"."
|
"."
|
||||||
}
|
}
|
||||||
|
@ -80,9 +81,9 @@ pub async fn index_handler() -> Markup {
|
||||||
&html! {
|
&html! {
|
||||||
h1 { "Blog Articles" }
|
h1 { "Blog Articles" }
|
||||||
p {
|
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" }
|
a href="/feed" { "RSS Feed" }
|
||||||
"."
|
" too!"
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
|
@ -113,7 +114,7 @@ static FEED: LazyLock<Bytes> = LazyLock::new(|| {
|
||||||
|
|
||||||
let items = ENTRIES.iter().map(|(path, (metadata, body))| {
|
let items = ENTRIES.iter().map(|(path, (metadata, body))| {
|
||||||
ItemBuilder::default()
|
ItemBuilder::default()
|
||||||
.link(Some(format!("{url}{path}")))
|
.link(Some(format!("{url}blog/{path}")))
|
||||||
.title(Some(metadata.title.clone()))
|
.title(Some(metadata.title.clone()))
|
||||||
.description(metadata.description.clone())
|
.description(metadata.description.clone())
|
||||||
.author(Some("contact@rgbcu.be".to_string()))
|
.author(Some("contact@rgbcu.be".to_string()))
|
||||||
|
|
14
src/routes/blog/test.md
Normal file
14
src/routes/blog/test.md
Normal file
|
@ -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.
|
|
@ -12,10 +12,42 @@ use serde::Deserialize;
|
||||||
|
|
||||||
use crate::markdown;
|
use crate::markdown;
|
||||||
|
|
||||||
|
mod ddmmyyyy {
|
||||||
|
use chrono::{
|
||||||
|
DateTime,
|
||||||
|
NaiveDate,
|
||||||
|
Utc,
|
||||||
|
};
|
||||||
|
use serde::{
|
||||||
|
self,
|
||||||
|
Deserialize,
|
||||||
|
Deserializer,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<DateTime<Utc>>, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
match Option::<String>::deserialize(deserializer)? {
|
||||||
|
None => Ok(None),
|
||||||
|
Some(s) => {
|
||||||
|
Ok(Some(DateTime::<Utc>::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)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct Metadata {
|
pub struct Metadata {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub description: Option<String>,
|
pub description: Option<String>,
|
||||||
|
#[serde(default, with = "ddmmyyyy")]
|
||||||
pub date: Option<DateTime<Utc>>,
|
pub date: Option<DateTime<Utc>>,
|
||||||
pub tags: Option<Vec<String>>,
|
pub tags: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue