Skip to content

Commit bf3eb91

Browse files
committed
list the other blogs in the main index
This...doesn't look great yet.
1 parent 5e048eb commit bf3eb91

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,18 @@ impl Generator {
131131
}
132132

133133
fn render_index(&self, blog: &Blog) -> Result<(), Box<dyn Error>> {
134+
let other_blogs: Vec<_> = self.blogs.iter().filter(|b| b.index_title() != blog.index_title())
135+
.map(|other_blog| json!({
136+
"name": other_blog.index_title(),
137+
"url": other_blog.prefix().join("index.html"),
138+
}))
139+
.collect();
140+
134141
let data = json!({
135142
"title": blog.index_title(),
136143
"parent": "layout",
137144
"blog": blog,
145+
"other_blogs": other_blogs,
138146
});
139147
self.render_template(blog.prefix().join("index.html"), "index", data)?;
140148
Ok(())

templates/index.hbs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22
<header class="mt3 mt0-ns mb6-ns">
33
<div class="container flex flex-column flex-row-l justify-between-l">
44
<div class="mw8-l">
5-
<h1>Blog</h1>
5+
<h1>Posts</h1>
6+
</div>
7+
</div>
8+
<div class="container flex flex-column flex-row-l justify-between-l">
9+
<div class="mw8-l">
10+
<b>See also:</b>
11+
{{#each other_blogs}}
12+
<a href="{{url}}">{{name}}</a>
13+
{{/each}}
614
</div>
715
</div>
816
</header>

0 commit comments

Comments
 (0)