Warn about ignored pages
This commit is contained in:
parent
7099fc8ac2
commit
f3edef2640
|
@ -7,6 +7,7 @@ use gutenberg::Site;
|
||||||
pub fn build(config_file: &str) -> Result<()> {
|
pub fn build(config_file: &str) -> Result<()> {
|
||||||
let mut site = Site::new(env::current_dir().unwrap(), config_file)?;
|
let mut site = Site::new(env::current_dir().unwrap(), config_file)?;
|
||||||
site.load()?;
|
site.load()?;
|
||||||
println!("-> Creating {} pages and {} sections", site.pages.len(), site.sections.len());
|
super::notify_site_size(&site);
|
||||||
|
super::warn_about_ignored_pages(&site);
|
||||||
site.build()
|
site.build()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,3 +5,24 @@ mod serve;
|
||||||
pub use self::init::create_new_project;
|
pub use self::init::create_new_project;
|
||||||
pub use self::build::build;
|
pub use self::build::build;
|
||||||
pub use self::serve::serve;
|
pub use self::serve::serve;
|
||||||
|
|
||||||
|
use gutenberg::Site;
|
||||||
|
|
||||||
|
use console::warn;
|
||||||
|
|
||||||
|
fn notify_site_size(site: &Site) {
|
||||||
|
println!("-> Creating {} pages and {} sections", site.pages.len(), site.sections.len());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn warn_about_ignored_pages(site: &Site) {
|
||||||
|
let ignored_pages = site.get_ignored_pages();
|
||||||
|
if !ignored_pages.is_empty() {
|
||||||
|
warn(&format!(
|
||||||
|
"{} page(s) ignored (missing date or order in a sorted section):",
|
||||||
|
ignored_pages.len()
|
||||||
|
));
|
||||||
|
for path in site.get_ignored_pages() {
|
||||||
|
warn(&format!("- {}", path.display()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -67,7 +67,8 @@ pub fn serve(interface: &str, port: &str, config_file: &str) -> Result<()> {
|
||||||
|
|
||||||
site.load()?;
|
site.load()?;
|
||||||
site.enable_live_reload();
|
site.enable_live_reload();
|
||||||
println!("-> Creating {} pages and {} sections", site.pages.len(), site.sections.len());
|
super::notify_site_size(&site);
|
||||||
|
super::warn_about_ignored_pages(&site);
|
||||||
site.build()?;
|
site.build()?;
|
||||||
report_elapsed_time(start);
|
report_elapsed_time(start);
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,13 @@ impl Site {
|
||||||
self.live_reload = true;
|
self.live_reload = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_ignored_pages(&self) -> Vec<PathBuf> {
|
||||||
|
self.sections
|
||||||
|
.values()
|
||||||
|
.flat_map(|s| s.ignored_pages.iter().map(|p| p.file_path.clone()))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Used by tests to change the output path to a tmp dir
|
/// Used by tests to change the output path to a tmp dir
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub fn set_output_path<P: AsRef<Path>>(&mut self, path: P) {
|
pub fn set_output_path<P: AsRef<Path>>(&mut self, path: P) {
|
||||||
|
|
Loading…
Reference in a new issue