From 6508b7e4d33f4a4a0309291bcdd866150fbe60a7 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Mon, 19 Jun 2017 18:14:13 +0900 Subject: [PATCH] Name the index section --- CHANGELOG.md | 1 + src/site.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9a78f1..4af6ece 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Add `section` to a page Tera context if there is one - Add `aliases` to pages for when you are changing urls but want to redirect to the new one +- Name the homepage section `index` (previously empty string) ## 0.0.6 (2017-05-24) diff --git a/src/site.rs b/src/site.rs index cfdba8b..78a6dcb 100644 --- a/src/site.rs +++ b/src/site.rs @@ -499,10 +499,12 @@ impl Site { /// Create a hashmap of paths to section /// For example `content/posts/_index.md` key will be `posts` + /// The index section will always be called `index` so don't use a path such as + /// `content/index/_index.md` yourself fn get_sections_map(&self) -> HashMap { self.sections .values() - .map(|s| (s.file.components.join("/"), s.clone())) + .map(|s| (if s.is_index() { "index".to_string() } else { s.file.components.join("/") }, s.clone())) .collect() }