Basic markdown with Tailwind CSS Typography

This commit is contained in:
Alphonse Paix
2025-09-20 14:03:13 +02:00
parent 38cb594882
commit bf2ec15e71
10 changed files with 83 additions and 18 deletions

View File

@@ -14,4 +14,11 @@ impl PostEntry {
pub fn formatted_date(&self) -> String {
self.published_at.format("%B %d, %Y").to_string()
}
pub fn to_html(self) -> Self {
Self {
content: markdown::to_html(&self.content),
..self
}
}
}

View File

@@ -51,7 +51,8 @@ pub async fn see_post(
let post = get_post(&connection_pool, post_id)
.await
.context(format!("Failed to fetch post #{}", post_id))
.map_err(AppError::unexpected_page)?;
.map_err(AppError::unexpected_page)?
.to_html();
let template = PostTemplate { post };
Ok(Html(template.render().unwrap()).into_response())
}