articles: parse body as markdown
This commit is contained in:
parent
ca2471485c
commit
77c75010b4
6 changed files with 706 additions and 24 deletions
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue