pub fn load(&mut self) -> Result<()> {
        let base_path = self.base_path.to_string_lossy().replace("\\", "/");
        let content_glob = format!("{}/{}", base_path, "content/**/*.md");

        let (section_entries, page_entries): (Vec<_>, Vec<_>) = glob(&content_glob)
            .expect("Invalid glob")
            .filter_map(|e| e.ok())
            .filter(|e| !e.as_path().file_name().unwrap().to_str().unwrap().starts_with('.'))
            .partition(|entry| {
                entry.as_path().file_name().unwrap().to_str().unwrap().starts_with("_index.")
            });

        self.library = Arc::new(RwLock::new(Library::new(
            page_entries.len(),
            section_entries.len(),
            self.config.is_multilingual(),
        )));

        let sections = {
            let config = &self.config;

            section_entries
                .into_par_iter()
                .map(|entry| {
                    let path = entry.as_path();
                    Section::from_file(path, config, &self.base_path)
                })
                .collect::<Vec<_>>()
        };

        let pages = {
            let config = &self.config;

            page_entries
                .into_par_iter()
                .filter(|entry| match &config.ignored_content_globset {
                    Some(gs) => !gs.is_match(entry.as_path()),
                    None => true,
                })
                .map(|entry| {
                    let path = entry.as_path();
                    Page::from_file(path, config, &self.base_path)
                })
                .collect::<Vec<_>>()
        };

        // Kinda duplicated code for add_section/add_page but necessary to do it that
        // way because of the borrow checker
        for section in sections {
            let s = section?;
            self.add_section(s, false)?;
        }

        self.create_default_index_sections()?;

        let mut pages_insert_anchors = HashMap::new();
        for page in pages {
            let p = page?;
            // Should draft pages be ignored?
            if p.meta.draft && !self.include_drafts {
                continue;
            }
            pages_insert_anchors.insert(
                p.file.path.clone(),
                self.find_parent_section_insert_anchor(&p.file.parent.clone(), &p.lang),
            );
            self.add_page(p, false)?;
        }

        {
            let library = self.library.read().unwrap();
            let collisions = library.check_for_path_collisions();
            if !collisions.is_empty() {
                return Err(Error::from_collisions(collisions));
            }
        }

        // taxonomy Tera fns are loaded in `register_early_global_fns`
        // so we do need to populate it first.
        self.populate_taxonomies()?;
        tpls::register_early_global_fns(self);
        self.populate_sections();
        self.render_markdown()?;
        tpls::register_tera_global_fns(self);

        // Needs to be done after rendering markdown as we only get the anchors at that point
        link_checking::check_internal_links_with_anchors(&self)?;

        if self.config.is_in_check_mode() {
            link_checking::check_external_links(&self)?;
        }

        Ok(())
    }
/// Reads all .md files in the `content` directory and create pages/sections
/// out of them
Reads all .md files in the `content` directory and create pages/sections
out of them
Reads all . md files in the ` content ` directory and create pages / sections out of them
pub fn load(&mut self) -> Result<()> {
        let base_path = self.base_path.to_string_lossy().replace("\\", "/");
        let content_glob = format!("{}/{}", base_path, "content/**/*.md");
        let (section_entries, page_entries): (Vec<_>, Vec<_>) = glob(&content_glob)
            .expect("Invalid glob")
            .filter_map(|e| e.ok())
            .filter(|e| !e.as_path().file_name().unwrap().to_str().unwrap().starts_with('.'))
            .partition(|entry| {
                entry.as_path().file_name().unwrap().to_str().unwrap().starts_with("_index.")
            });
        self.library = Arc::new(RwLock::new(Library::new(
            page_entries.len(),
            section_entries.len(),
            self.config.is_multilingual(),
        )));
        let sections = {
            let config = &self.config;
            section_entries
                .into_par_iter()
                .map(|entry| {
                    let path = entry.as_path();
                    Section::from_file(path, config, &self.base_path)
                })
                .collect::<Vec<_>>()
        };
        let pages = {
            let config = &self.config;
            page_entries
                .into_par_iter()
                .filter(|entry| match &config.ignored_content_globset {
                    Some(gs) => !gs.is_match(entry.as_path()),
                    None => true,
                })
                .map(|entry| {
                    let path = entry.as_path();
                    Page::from_file(path, config, &self.base_path)
                })
                .collect::<Vec<_>>()
        };
        // Kinda duplicated code for add_section/add_page but necessary to do it that
        // way because of the borrow checker
        for section in sections {
            let s = section?;
            self.add_section(s, false)?;
        }
        self.create_default_index_sections()?;
        let mut pages_insert_anchors = HashMap::new();
        for page in pages {
            let p = page?;
            // Should draft pages be ignored?
            if p.meta.draft && !self.include_drafts {
                continue;
            }
            pages_insert_anchors.insert(
                p.file.path.clone(),
                self.find_parent_section_insert_anchor(&p.file.parent.clone(), &p.lang),
            );
            self.add_page(p, false)?;
        }
        {
            let library = self.library.read().unwrap();
            let collisions = library.check_for_path_collisions();
            if !collisions.is_empty() {
                return Err(Error::from_collisions(collisions));
            }
        }
        // taxonomy Tera fns are loaded in `register_early_global_fns`
        // so we do need to populate it first.
        self.populate_taxonomies()?;
        tpls::register_early_global_fns(self);
        self.populate_sections();
        self.render_markdown()?;
        tpls::register_tera_global_fns(self);
        // Needs to be done after rendering markdown as we only get the anchors at that point
        link_checking::check_internal_links_with_anchors(&self)?;
        if self.config.is_in_check_mode() {
            link_checking::check_external_links(&self)?;
        }
        Ok(())
    }
pub fn load ( & mut self ) -> Result < ( ) > { let base_path = self . base_path . to_string_lossy ( ) . replace ( " \\ " , " " ) ; let content_glob = format ! ( " " base_path " " ) ; let ( section_entries , page_entries ) : ( Vec < _ > , Vec < _ > ) = glob ( & content_glob ) . expect ( " " ) . filter_map ( | e | e . ok ( ) ) . filter ( | e | ! e . as_path ( ) . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . starts_with ( '.' ) ) . partition ( | entry | { entry . as_path ( ) . file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) . starts_with ( " " ) } ) ; self . library = Arc :: new ( RwLock :: new ( Library :: new ( page_entries . len ( ) , section_entries . len ( ) , self . config . is_multilingual ( ) , ) ) ) ; let sections = { let config = & self . config ; section_entries . into_par_iter ( ) . map ( | entry | { let path = entry . as_path ( ) ; Section :: from_file ( path , config , & self . base_path ) } ) . collect :: < Vec < _ > > ( ) } ; let pages = { let config = & self . config ; page_entries . into_par_iter ( ) . filter ( | entry | match & config . ignored_content_globset { Some ( gs ) => ! gs . is_match ( entry . as_path ( ) ) , None => true , } ) . map ( | entry | { let path = entry . as_path ( ) ; Page :: from_file ( path , config , & self . base_path ) } ) . collect :: < Vec < _ > > ( ) } ; // Kinda duplicated code for add_section/add_page but necessary to do it that // way because of the borrow checker for section in sections { let s = section ? ; self . add_section ( s , false ) ? ; } self . create_default_index_sections ( ) ? ; let mut pages_insert_anchors = HashMap :: new ( ) ; for page in pages { let p = page ? ; // Should draft pages be ignored? if p . meta . draft && ! self . include_drafts { continue ; } pages_insert_anchors . insert ( p . file . path . clone ( ) , self . find_parent_section_insert_anchor ( & p . file . parent . clone ( ) , & p . lang ) , ) ; self . add_page ( p , false ) ? ; } { let library = self . library . read ( ) . unwrap ( ) ; let collisions = library . check_for_path_collisions ( ) ; if ! collisions . is_empty ( ) { return Err ( Error :: from_collisions ( collisions ) ) ; } } // taxonomy Tera fns are loaded in `register_early_global_fns` // so we do need to populate it first. self . populate_taxonomies ( ) ? ; tpls :: register_early_global_fns ( self ) ; self . populate_sections ( ) ; self . render_markdown ( ) ? ; tpls :: register_tera_global_fns ( self ) ; // Needs to be done after rendering markdown as we only get the anchors at that point link_checking :: check_internal_links_with_anchors ( & self ) ? ; if self . config . is_in_check_mode ( ) { link_checking :: check_external_links ( & self ) ? ; } Ok ( ( ) ) }
Reads all .md files in the `content` directory and create pages/sections
out of them
Reads all . md files in the ` content ` directory and create pages / sections out of them
&mut self
&mut self