zola/src/cmd/check.rs

30 lines
724 B
Rust
Raw Normal View History

2020-02-10 19:48:52 +00:00
use std::path::{Path, PathBuf};
use errors::Result;
use site::Site;
2019-12-21 21:52:39 +00:00
use crate::console;
2019-08-24 20:23:08 +00:00
pub fn check(
root_dir: &Path,
config_file: &Path,
2019-08-24 20:23:08 +00:00
base_path: Option<&str>,
base_url: Option<&str>,
include_drafts: bool,
) -> Result<()> {
let bp = base_path.map(PathBuf::from).unwrap_or_else(|| PathBuf::from(root_dir));
let mut site = Site::new(bp, config_file)?;
// Force the checking of external links
2019-07-12 21:09:05 +00:00
site.config.enable_check_mode();
if let Some(b) = base_url {
site.set_base_url(b.to_string());
}
2019-08-24 20:23:08 +00:00
if include_drafts {
site.include_drafts();
}
site.load()?;
2019-07-12 21:43:07 +00:00
console::check_site_summary(&site);
console::warn_about_ignored_pages(&site);
Ok(())
}