aboutsummaryrefslogtreecommitdiff
path: root/src/blog.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/blog.rs')
-rw-r--r--src/blog.rs21
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);