diff options
Diffstat (limited to '')
-rw-r--r-- | src/posts/mod.rs | 13 |
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, |