From 46e6b5fa84b1ec6e08f124c478909ec745562214 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 14 May 2022 20:46:31 +0200 Subject: feat: Add title and date into the post template Now post template has title and created date by defaul. --- src/blog.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/blog.rs b/src/blog.rs index 6c190a9..e549fb2 100644 --- a/src/blog.rs +++ b/src/blog.rs @@ -21,6 +21,8 @@ struct IndexTemplate { #[template(path = "post.html")] struct PostTemplate { content: String, + title: String, + date: String } pub struct BlogEntry { @@ -62,7 +64,13 @@ fn get_file_content(path: &str) -> String { pub fn render_post_page(path: &String) -> String { - PostTemplate { content: get_file_content(path) } + let blog = BlogEntry::new(path); + + PostTemplate { + content: get_file_content(path), + title: blog.title, + date: blog.datetime.format("%Y-%m-%d").to_string() + } .render_once() .unwrap() } -- cgit v1.2.3