Start implementing _index folder for section content/assets
@@ -180,14 +180,20 @@ impl Site {
let (section_entries, page_entries): (Vec<_>, Vec<_>) = glob(&content_glob)
.unwrap()
.filter_map(|e| e.ok())
- .partition(|entry| entry.as_path().file_name().unwrap() == "_index.md");
+ // If file is _index.md and it doesn't have a sibling folder called _index containing an index.md (which have priority), we have a section
+ // If parent folder is _index and file is index.md then we have a section
+ .partition(|entry| ( (entry.as_path().file_name().unwrap() == "_index.md" && !entry.as_path().parent().unwrap().join("_index/index.md").is_file()) || (entry.as_path().parent().unwrap().file_name().unwrap() == "_index" && entry.as_path().file_name().unwrap() == "index.md")));
+
+ println!("Now section_entries");
+ println!("{:?}", section_entries);
let sections = {
let config = &self.config;
section_entries
.into_par_iter()
- .filter(|entry| entry.as_path().file_name().unwrap() == "_index.md")
+ // Is it really necessary to refilter for _index.md/index.md after the partition took place?
+ //.filter(|entry| entry.as_path().file_name().unwrap() == "_index.md")
.map(|entry| {
let path = entry.as_path();
Section::from_file(path, config)
@@ -195,11 +201,15 @@ impl Site {
.collect::<Vec<_>>()
};
+ println!("Now sections:");
+ println!("{:?}", sections);
+
let pages = {
let config = &self.config;
page_entries
.into_par_iter()
+ // Same question. Do we have to refilter here given we have already partitioned results from the glob?
.filter(|entry| entry.as_path().file_name().unwrap() != "_index.md")
.map(|entry| {
let path = entry.as_path();
@@ -216,7 +226,7 @@ impl Site {
}
// Insert a default index section if necessary so we don't need to create
- // a _index.md to render the index page
+ // a _index.md to render the index page at the root of the site
let index_path = self.index_section_path();
if let Some(ref index_section) = self.sections.get(&index_path) {
if self.config.build_search_index && !index_section.meta.in_search_index {
