Revert "Start implementing _index folder for section content/assets"
This reverts commit c7156a84f0
.
This commit is contained in:
parent
c7156a84f0
commit
3b9c8c71b5
|
@ -82,17 +82,9 @@ impl Section {
|
||||||
pub fn from_file<P: AsRef<Path>>(path: P, config: &Config) -> Result<Section> {
|
pub fn from_file<P: AsRef<Path>>(path: P, config: &Config) -> Result<Section> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
let content = read_file(path)?;
|
let content = read_file(path)?;
|
||||||
println!("Parsing from file {:?}", path);
|
|
||||||
let mut section = Section::parse(path, &content, config)?;
|
let mut section = Section::parse(path, &content, config)?;
|
||||||
|
|
||||||
println!("filename {:?}", section.file.name);
|
if section.file.name == "_index" {
|
||||||
// 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
|
|
||||||
let parent_dir = path.parent().unwrap();
|
let parent_dir = path.parent().unwrap();
|
||||||
let assets = find_related_assets(parent_dir);
|
let assets = find_related_assets(parent_dir);
|
||||||
|
|
||||||
|
|
|
@ -180,20 +180,14 @@ impl Site {
|
||||||
let (section_entries, page_entries): (Vec<_>, Vec<_>) = glob(&content_glob)
|
let (section_entries, page_entries): (Vec<_>, Vec<_>) = glob(&content_glob)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.filter_map(|e| e.ok())
|
.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
|
.partition(|entry| entry.as_path().file_name().unwrap() == "_index.md");
|
||||||
// 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 sections = {
|
||||||
let config = &self.config;
|
let config = &self.config;
|
||||||
|
|
||||||
section_entries
|
section_entries
|
||||||
.into_par_iter()
|
.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| {
|
.map(|entry| {
|
||||||
let path = entry.as_path();
|
let path = entry.as_path();
|
||||||
Section::from_file(path, config)
|
Section::from_file(path, config)
|
||||||
|
@ -201,15 +195,11 @@ impl Site {
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("Now sections:");
|
|
||||||
println!("{:?}", sections);
|
|
||||||
|
|
||||||
let pages = {
|
let pages = {
|
||||||
let config = &self.config;
|
let config = &self.config;
|
||||||
|
|
||||||
page_entries
|
page_entries
|
||||||
.into_par_iter()
|
.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")
|
.filter(|entry| entry.as_path().file_name().unwrap() != "_index.md")
|
||||||
.map(|entry| {
|
.map(|entry| {
|
||||||
let path = entry.as_path();
|
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
|
// 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();
|
let index_path = self.index_section_path();
|
||||||
if let Some(ref index_section) = self.sections.get(&index_path) {
|
if let Some(ref index_section) = self.sections.get(&index_path) {
|
||||||
if self.config.build_search_index && !index_section.meta.in_search_index {
|
if self.config.build_search_index && !index_section.meta.in_search_index {
|
||||||
|
|
Loading…
Reference in a new issue