|
@@ -66,10 +66,16 @@ fn render_post(cwd: &path::PathBuf, layout: &str, post: &Post) {
|
66
|
66
|
}
|
67
|
67
|
|
68
|
68
|
fn render_post_listing(cwd: &path::PathBuf, layout: &str, posts: &Vec<Post>) {
|
|
69
|
+ let post_item_template =
|
|
70
|
+ fs::read_to_string(cwd.join("templates").join("post_listing_item.html"))
|
|
71
|
+ .expect("Couldn't find post listing item template");
|
69
|
72
|
let post_listing = posts
|
70
|
73
|
.iter()
|
71
|
|
- .map(|ref post| format!("<li><a href='/{}/'>{}</a></li>", post.slug, post.title))
|
72
|
|
- .collect::<Vec<String>>()
|
|
74
|
+ .map(|ref post| {
|
|
75
|
+ post_item_template
|
|
76
|
+ .replace("{{ slug }}", &post.slug)
|
|
77
|
+ .replace("{{ title }}", &post.title)
|
|
78
|
+ }).collect::<Vec<String>>()
|
73
|
79
|
.join("\n");
|
74
|
80
|
|
75
|
81
|
let output = layout.replace("{{ contents }}", &post_listing);
|