mirror of
https://github.com/zyllian/webdog.git
synced 2025-01-17 19:22:21 -08:00
move build_all_pages
to the site builder
This commit is contained in:
parent
dabf4bbe1a
commit
71bd753b05
3 changed files with 14 additions and 15 deletions
|
@ -5,6 +5,7 @@ use std::{collections::HashMap, path::PathBuf};
|
|||
use eyre::{eyre, Context, OptionExt};
|
||||
use lol_html::{element, html_content::ContentType, HtmlRewriter, Settings};
|
||||
use pulldown_cmark::{Options, Parser};
|
||||
use rayon::prelude::*;
|
||||
use serde::Serialize;
|
||||
use syntect::{highlighting::ThemeSet, parsing::SyntaxSet};
|
||||
use tera::Tera;
|
||||
|
@ -458,6 +459,16 @@ impl SiteBuilder {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Builds all of the site's standard pages.
|
||||
pub fn build_all_pages(&self) -> eyre::Result<()> {
|
||||
self.site
|
||||
.page_index
|
||||
.keys()
|
||||
.par_bridge()
|
||||
.try_for_each(|page_name| self.build_page(page_name))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Builds all resource types.
|
||||
pub fn build_all_resources(&self) -> eyre::Result<()> {
|
||||
for builder in self.resource_builders.values() {
|
||||
|
@ -476,7 +487,7 @@ impl SiteBuilder {
|
|||
|
||||
/// Builds the entire site.
|
||||
pub fn build_all(&self) -> eyre::Result<()> {
|
||||
self.site.build_all_pages(self)?;
|
||||
self.build_all_pages()?;
|
||||
self.build_sass()?;
|
||||
|
||||
for (_source_path, config) in self.site.config.resources.iter() {
|
||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -14,7 +14,6 @@ use std::{
|
|||
|
||||
use extras::ExtraData;
|
||||
use eyre::Context;
|
||||
use rayon::prelude::*;
|
||||
use resource::{EmbedMetadata, ResourceBuilderConfig};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
@ -180,14 +179,4 @@ impl Site {
|
|||
pub fn build_once(self) -> eyre::Result<()> {
|
||||
SiteBuilder::new(self, false)?.prepare()?.build_all()
|
||||
}
|
||||
|
||||
/// Helper method to build all available pages.
|
||||
fn build_all_pages(&self, builder: &SiteBuilder) -> eyre::Result<()> {
|
||||
self.page_index
|
||||
.keys()
|
||||
.par_bridge()
|
||||
.try_for_each(|page_name| builder.build_page(page_name))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ fn create(
|
|||
} else if let Ok(_template_path) = relative_path.strip_prefix(TEMPLATES_PATH) {
|
||||
builder.tera.full_reload()?;
|
||||
if build {
|
||||
builder.site.build_all_pages(builder)?;
|
||||
builder.build_all_pages()?;
|
||||
builder.build_all_resources()?;
|
||||
}
|
||||
} else if relative_path.display().to_string() == SiteConfig::FILENAME {
|
||||
|
@ -126,8 +126,7 @@ fn remove(builder: &mut SiteBuilder, path: &Path, relative_path: &Path) -> eyre:
|
|||
} else if let Ok(_template_path) = relative_path.strip_prefix(TEMPLATES_PATH) {
|
||||
builder.tera.full_reload()?;
|
||||
builder
|
||||
.site
|
||||
.build_all_pages(builder)
|
||||
.build_all_pages()
|
||||
.wrap_err("Failed to rebuild pages")?;
|
||||
} else if let Ok(_sass_path) = relative_path.strip_prefix(SASS_PATH) {
|
||||
builder.build_sass().wrap_err("Failed to rebuild Sass")?;
|
||||
|
|
Loading…
Add table
Reference in a new issue