From 3b9c8c71b50954fed4b6840ccde7433eaccb65c3 Mon Sep 17 00:00:00 2001 From: cmal Date: Thu, 9 Aug 2018 11:51:01 +0200 Subject: [PATCH] Revert "Start implementing _index folder for section content/assets" This reverts commit c7156a84f0ca4132c3380d75ba993f379a967cb5. --- components/content/src/section.rs | 10 +--------- components/site/src/lib.rs | 16 +++------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/components/content/src/section.rs b/components/content/src/section.rs index 905c532a..73727410 100644 --- a/components/content/src/section.rs +++ b/components/content/src/section.rs @@ -82,17 +82,9 @@ impl Section { pub fn from_file>(path: P, config: &Config) -> Result
{ let path = path.as_ref(); let content = read_file(path)?; - println!("Parsing from file {:?}", path); let mut section = Section::parse(path, &content, config)?; - println!("filename {:?}", section.file.name); - // I don't see any reason why, but section.file.name always is "_index"! ← bug - - let file_name = path.file_name().unwrap(); - - // Is this check really necessary? Should the else case happen at all? - if file_name == "_index.md" || file_name == "index.md" { - // In any case, we're looking for assets inside parent directory + if section.file.name == "_index" { let parent_dir = path.parent().unwrap(); let assets = find_related_assets(parent_dir); diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index b293b0ee..5d4236ac 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -180,20 +180,14 @@ impl Site { let (section_entries, page_entries): (Vec<_>, Vec<_>) = glob(&content_glob) .unwrap() .filter_map(|e| e.ok()) - // 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); + .partition(|entry| entry.as_path().file_name().unwrap() == "_index.md"); let sections = { let config = &self.config; section_entries .into_par_iter() - // 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") + .filter(|entry| entry.as_path().file_name().unwrap() == "_index.md") .map(|entry| { let path = entry.as_path(); Section::from_file(path, config) @@ -201,15 +195,11 @@ impl Site { .collect::>() }; - 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(); @@ -226,7 +216,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 at the root of the site + // a _index.md to render the index page 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 {