articles: parse body as markdown

This commit is contained in:
Agahnim 2026-05-13 14:21:24 +02:00
parent ca2471485c
commit 77c75010b4
Signed by: Agahnim
SSH key fingerprint: SHA256:Zj65PJnE0dRYye8Ltk/qDglynyXUxJngQ9qqx/VI+b4
6 changed files with 706 additions and 24 deletions

View file

@ -1,4 +1,5 @@
use chrono::NaiveDate;
use comrak::{markdown_to_html, ComrakOptions};
use serde::Deserialize;
pub struct AppState {
@ -28,6 +29,11 @@ impl AppState {
)
.expect("JSON invalide");
for article in &mut news {
article.body_html =
markdown_to_html(&article.body, &ComrakOptions::default());
}
news.sort_by(|a, b| b.date.cmp(&a.date));
news
@ -53,4 +59,6 @@ pub struct Track {
pub struct WebsiteArticle {
pub date: NaiveDate,
pub body: String,
#[serde(skip)]
pub body_html: String,
}