diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-05-14 20:46:31 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-05-14 20:50:37 +0200 |
commit | 46e6b5fa84b1ec6e08f124c478909ec745562214 (patch) | |
tree | 699ba761d42c79257b81cd1d01ba3e1da99c106c /src | |
parent | d279a9137601f66685a6bbf1e4f7db162b06e661 (diff) | |
download | macroblog.rs-46e6b5fa84b1ec6e08f124c478909ec745562214.tar.gz macroblog.rs-46e6b5fa84b1ec6e08f124c478909ec745562214.tar.bz2 macroblog.rs-46e6b5fa84b1ec6e08f124c478909ec745562214.zip |
feat: Add title and date into the post template
Now post template has title and created date by defaul.
Diffstat (limited to 'src')
-rw-r--r-- | src/blog.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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() } |