aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2023-08-19 00:56:35 +0100
committerLibravatar cel 🌸 <cel@blos.sm>2023-08-19 00:56:35 +0100
commitd1c5d0c3010cc11cbb249b056b77e65cbb7f9468 (patch)
treed33bcc8466a5eecb6d940a318e3fa1249fb60b92 /src
parent3a214e407ffdd892ab6d59c7f6259234aa4f5778 (diff)
downloadblossom-d1c5d0c3010cc11cbb249b056b77e65cbb7f9468.tar.gz
blossom-d1c5d0c3010cc11cbb249b056b77e65cbb7f9468.tar.bz2
blossom-d1c5d0c3010cc11cbb249b056b77e65cbb7f9468.zip
enable html and checkbox checkability when rendering blogposts
Diffstat (limited to 'src')
-rw-r--r--src/posts/mod.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/posts/mod.rs b/src/posts/mod.rs
index 7f8e6c4..c75dd53 100644
--- a/src/posts/mod.rs
+++ b/src/posts/mod.rs
@@ -6,7 +6,7 @@ use std::collections::HashSet;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
-use markdown::{mdast::Node, Constructs, Options, ParseOptions};
+use markdown::{mdast::Node, CompileOptions, Constructs, Options, ParseOptions};
use rocket::http::Status;
use serde::{ser::SerializeStruct, Deserialize, Serialize};
use tokio::fs;
@@ -22,7 +22,7 @@ enum PostType {
#[derive(Debug)]
pub struct Post<D: Content> {
- // id: i64,
+ id: String,
subject: Option<String>,
created_at: DateTime<Utc>,
updated_at: Option<DateTime<Utc>>,
@@ -182,11 +182,15 @@ impl Content for Article {
parse: ParseOptions {
constructs: Constructs {
frontmatter: true,
- ..Constructs::default()
+ ..Constructs::gfm()
},
..ParseOptions::default()
},
- ..Options::default()
+ compile: CompileOptions {
+ gfm_task_list_item_checkable: true,
+ allow_dangerous_html: true,
+ ..CompileOptions::default()
+ },
};
Ok(markdown::to_html_with_options(&buf, &options).unwrap())
}
@@ -211,6 +215,7 @@ impl Post<Article> {
};
Ok(Post {
+ id: article.name.to_owned(),
subject: Some(metadata.title),
created_at: metadata.created_at.parse::<DateTime<Utc>>()?,
updated_at,