aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index cabff0e..63a5386 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,10 +9,15 @@ use hyper::service::{make_service_fn, service_fn};
use sailfish::TemplateOnce;
use ::router::Router;
+struct PostEntry {
+ title: String,
+ file: String,
+}
+
#[derive(TemplateOnce)]
#[template(path = "index.html")]
struct IndexTemplate {
- posts: Vec<String>,
+ posts: Vec<PostEntry>,
}
#[derive(TemplateOnce)]
@@ -35,9 +40,19 @@ fn get_file_content(path: &str) -> String {
return String::from_utf8(buffer).unwrap();
}
-fn get_post_title() -> Vec<String> {
+fn get_post_entry(path: &String) -> PostEntry {
+ let sub_title = str::replace(path, "_", " ");
+ let title = str::replace(sub_title.as_str(), ".html", "");
+ PostEntry {
+ title: String::from(title),
+ file: String::from(path),
+ }
+}
+
+fn get_post_title() -> Vec<PostEntry> {
PostAsset::iter()
.map(|e| format!("{}", e))
+ .map(|e| get_post_entry(&e))
.collect()
}