fix not rebuilding the entire site when config changes, resolves #18

This commit is contained in:
zyl 2024-11-15 07:06:43 -08:00
parent 111a261e7e
commit dabf4bbe1a
Signed by: zyl
SSH key fingerprint: SHA256:uxxbSXbdroP/OnKBGnEDk5q7EKB2razvstC/KmzdXXs
3 changed files with 16 additions and 13 deletions

View file

@ -473,4 +473,18 @@ impl SiteBuilder {
.ok_or_else(|| eyre!("missing resource: {resource}"))?
.build_all(self)
}
/// Builds the entire site.
pub fn build_all(&self) -> eyre::Result<()> {
self.site.build_all_pages(self)?;
self.build_sass()?;
for (_source_path, config) in self.site.config.resources.iter() {
let mut res_builder = ResourceBuilder::new(config.clone());
res_builder.load_all(self)?;
res_builder.build_all(self)?;
}
Ok(())
}
}

View file

@ -178,18 +178,7 @@ impl Site {
/// Builds the site once.
pub fn build_once(self) -> eyre::Result<()> {
let builder = SiteBuilder::new(self, false)?.prepare()?;
builder.site.build_all_pages(&builder)?;
builder.build_sass()?;
for (_source_path, config) in builder.site.config.resources.iter() {
let mut res_builder = resource::ResourceBuilder::new(config.clone());
res_builder.load_all(&builder)?;
res_builder.build_all(&builder)?;
}
Ok(())
SiteBuilder::new(self, false)?.prepare()?.build_all()
}
/// Helper method to build all available pages.

View file

@ -98,7 +98,7 @@ fn create(
let new_config = serde_yml::from_str(&std::fs::read_to_string(path)?)?;
builder.site.config = new_config;
builder.reload()?;
builder.site.build_all_pages(builder)?;
builder.build_all()?;
} else if let Ok(_sass_path) = relative_path.strip_prefix(SASS_PATH) {
if build {
builder.build_sass().wrap_err("Failed to rebuild Sass")?;