pub fn create_default_index_sections(&mut self) -> Result<()> {
        for (index_path, lang) in self.index_section_paths() {
            if let Some(ref index_section) = self.library.read().unwrap().get_section(&index_path) {
                if self.config.build_search_index && !index_section.meta.in_search_index {
                    bail!(
                    "You have enabled search in the config but disabled it in the index section: \
                    either turn off the search in the config or remote `in_search_index = true` from the \
                    section front-matter."
                    )
                }
            }
            let mut library = self.library.write().expect("Get lock for load");
            // Not in else because of borrow checker
            if !library.contains_section(&index_path) {
                let mut index_section = Section::default();
                index_section.file.parent = self.content_path.clone();
                index_section.file.filename =
                    index_path.file_name().unwrap().to_string_lossy().to_string();
                if let Some(ref l) = lang {
                    index_section.file.name = format!("_index.{}", l);
                    index_section.path = format!("{}/", l);
                    index_section.permalink = self.config.make_permalink(l);
                    let filename = format!("_index.{}.md", l);
                    index_section.file.path = self.content_path.join(&filename);
                    index_section.file.relative = filename;
                } else {
                    index_section.file.name = "_index".to_string();
                    index_section.permalink = self.config.make_permalink("");
                    index_section.file.path = self.content_path.join("_index.md");
                    index_section.file.relative = "_index.md".to_string();
                    index_section.path = "/".to_string();
                }
                index_section.lang = index_section.file.find_language(&self.config)?;
                library.insert_section(index_section);
            }
        }

        Ok(())
    }
/// Insert a default index section for each language if necessary so we don't need to create
/// a _index.md to render the index page at the root of the site
Insert a default index section for each language if necessary so we don't need to create
a _index.md to render the index page at the root of the site
Insert a default index section for each language if necessary so we don ' t need to create a _index . md to render the index page at the root of the site
pub fn create_default_index_sections(&mut self) -> Result<()> {
        for (index_path, lang) in self.index_section_paths() {
            if let Some(ref index_section) = self.library.read().unwrap().get_section(&index_path) {
                if self.config.build_search_index && !index_section.meta.in_search_index {
                    bail!(
                    "You have enabled search in the config but disabled it in the index section: \
                    either turn off the search in the config or remote `in_search_index = true` from the \
                    section front-matter."
                    )
                }
            }
            let mut library = self.library.write().expect("Get lock for load");
            // Not in else because of borrow checker
            if !library.contains_section(&index_path) {
                let mut index_section = Section::default();
                index_section.file.parent = self.content_path.clone();
                index_section.file.filename =
                    index_path.file_name().unwrap().to_string_lossy().to_string();
                if let Some(ref l) = lang {
                    index_section.file.name = format!("_index.{}", l);
                    index_section.path = format!("{}/", l);
                    index_section.permalink = self.config.make_permalink(l);
                    let filename = format!("_index.{}.md", l);
                    index_section.file.path = self.content_path.join(&filename);
                    index_section.file.relative = filename;
                } else {
                    index_section.file.name = "_index".to_string();
                    index_section.permalink = self.config.make_permalink("");
                    index_section.file.path = self.content_path.join("_index.md");
                    index_section.file.relative = "_index.md".to_string();
                    index_section.path = "/".to_string();
                }
                index_section.lang = index_section.file.find_language(&self.config)?;
                library.insert_section(index_section);
            }
        }
        Ok(())
    }
pub fn create_default_index_sections ( & mut self ) -> Result < ( ) > { for ( index_path , lang ) in self . index_section_paths ( ) { if let Some ( ref index_section ) = self . library . read ( ) . unwrap ( ) . get_section ( & index_path ) { if self . config . build_search_index && ! index_section . meta . in_search_index { bail ! ( " \
 \
 " ) } } let mut library = self . library . write ( ) . expect ( " " ) ; // Not in else because of borrow checker if ! library . contains_section ( & index_path ) { let mut index_section = Section :: default ( ) ; index_section . file . parent = self . content_path . clone ( ) ; index_section . file . filename = index_path . file_name ( ) . unwrap ( ) . to_string_lossy ( ) . to_string ( ) ; if let Some ( ref l ) = lang { index_section . file . name = format ! ( " " l ) ; index_section . path = format ! ( " " l ) ; index_section . permalink = self . config . make_permalink ( l ) ; let filename = format ! ( " " l ) ; index_section . file . path = self . content_path . join ( & filename ) ; index_section . file . relative = filename ; } else { index_section . file . name = " " . to_string ( ) ; index_section . permalink = self . config . make_permalink ( " " ) ; index_section . file . path = self . content_path . join ( " " ) ; index_section . file . relative = " " . to_string ( ) ; index_section . path = " " . to_string ( ) ; } index_section . lang = index_section . file . find_language ( & self . config ) ? ; library . insert_section ( index_section ) ; } } Ok ( ( ) ) }
Insert a default index section for each language if necessary so we don't need to create
a _index.md to render the index page at the root of the site
Insert a default index section for each language if necessary so we don ' t need to create a _index . md to render the index page at the root of the site
&mut self
&mut self