Function hugo_to_json::create_page_index [−][src]
pub fn create_page_index(
contents_directory: PathBuf,
drafts: bool
) -> Result<TraverseResults, HugotoJsonError>
Given a contents directory it traverses all matching .md
files with TOML and YAML frontmatter.
Examples
use hugo_to_json::{create_page_index, page_index::PageIndex, operation_result::OperationResult, hugo_to_json_error::HugotoJsonError}; use std::path::PathBuf; let traverse_result = create_page_index(PathBuf::from("/home/example_user/documents/blog/contents/"), false)?; // We can then see if there were any errors. let indices: Vec<PageIndex> = traverse_result.page_index; let errors: Vec<OperationResult> = traverse_result.errors; if traverse_result.error_count > 0 { panic!("Errors found"); // Don't do this for real! }
Errors
A HugoToJsonError
should only occur if an IO error occurs trying to access the contents directory.
All other errors are stored in the errors property of the TraverseResults
.