25 lines
505 B
Rust
25 lines
505 B
Rust
use chrono::{DateTime, Utc};
|
|
use uuid::Uuid;
|
|
|
|
pub struct PostEntry {
|
|
pub post_id: Uuid,
|
|
pub author: Option<String>,
|
|
pub title: String,
|
|
pub content: String,
|
|
pub published_at: DateTime<Utc>,
|
|
}
|
|
|
|
impl PostEntry {
|
|
#[allow(dead_code)]
|
|
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
|
|
}
|
|
}
|
|
}
|