diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-06-11 18:15:38 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-06-11 18:15:38 +0200 |
commit | 6a31a30b98f7febe9ac0db74211ef074aefc7ad3 (patch) | |
tree | 9ce8694f0f37efcc5b1eb72d9e2d26731ad7ec6a /src/blog.rs | |
parent | 96c2cbe1850f95806cccb6f47a7739eb9c2ac860 (diff) | |
download | macroblog.rs-6a31a30b98f7febe9ac0db74211ef074aefc7ad3.tar.gz macroblog.rs-6a31a30b98f7febe9ac0db74211ef074aefc7ad3.tar.bz2 macroblog.rs-6a31a30b98f7febe9ac0db74211ef074aefc7ad3.zip |
feat: Add project tab
Diffstat (limited to 'src/blog.rs')
-rw-r--r-- | src/blog.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/blog.rs b/src/blog.rs index a1586f8..8c3af52 100644 --- a/src/blog.rs +++ b/src/blog.rs @@ -1,8 +1,7 @@ +use crate::assets::{BlogEntry, IndexTemplate, PostAsset, PostTemplate, ProjectsAsset, ProjectsTemplate}; use pulldown_cmark::{html, Options, Parser}; use sailfish::TemplateOnce; use std::str; -use crate::assets::{BlogEntry, PostAsset, IndexTemplate, PostTemplate}; - pub fn read_assets() -> Vec<BlogEntry> { let mut entries: Vec<BlogEntry> = PostAsset::iter() @@ -26,6 +25,24 @@ fn get_file_content(path: &str) -> String { return html_output.to_string(); } +fn get_projects_content() -> String { + let buffer = ProjectsAsset::get("index.md").unwrap().data.into_owned(); + let md = String::from_utf8(buffer).unwrap(); + let mut options = Options::empty(); + options.insert(Options::ENABLE_FOOTNOTES); + let parser = Parser::new_ext(&md, options); + let mut html_output = &mut String::new(); + html::push_html(&mut html_output, parser); + return html_output.to_string(); +} + +pub fn render_projects() -> String { + ProjectsTemplate { + content: get_projects_content(), + } + .render_once() + .unwrap() +} pub fn render_post_page(path: &String) -> String { let blog = BlogEntry::new(path); |