post card fragment

This commit is contained in:
Alphonse Paix
2025-09-23 16:09:25 +02:00
parent 03ca17fdb5
commit 5c5e3b0e4c
4 changed files with 54 additions and 43 deletions

View File

@@ -1,3 +1,5 @@
use crate::templates::PostCardTemplate;
use askama::Template;
use chrono::{DateTime, Utc};
use uuid::Uuid;
@@ -25,4 +27,8 @@ impl PostEntry {
Err(e) => anyhow::bail!(e),
}
}
pub fn render(&self) -> String {
PostCardTemplate { post: self }.render().unwrap()
}
}

View File

@@ -135,3 +135,9 @@ You're receiving this because you subscribed to the zero2prod newsletter."#,
)
}
}
#[derive(Template)]
#[template(path = "../templates/post_card_fragment.html")]
pub struct PostCardTemplate<'a> {
pub post: &'a PostEntry,
}