mirror of
https://github.com/zyllian/webdog.git
synced 2025-06-27 08:56:49 -07:00
add feature to set a custom path for static webdog resources
This commit is contained in:
parent
b4088fb397
commit
3daa80f8af
2 changed files with 12 additions and 3 deletions
|
@ -12,8 +12,8 @@ use url::Url;
|
|||
|
||||
use crate::{resource::ResourceBuilder, util, PageMetadata, Site, ROOT_PATH, SASS_PATH};
|
||||
|
||||
/// Path for static webdog resources included with the site build.
|
||||
const WEBDOG_PATH: &str = "webdog";
|
||||
/// Default path for static webdog resources included with the site build.
|
||||
const WEBDOG_DEFAULT_PATH: &str = "webdog";
|
||||
|
||||
/// Struct containing data to be sent to templates when rendering them.
|
||||
#[derive(Debug, Serialize)]
|
||||
|
@ -96,7 +96,13 @@ impl SiteBuilder {
|
|||
std::fs::create_dir(&self.build_path).wrap_err("Failed to create build directory")?;
|
||||
}
|
||||
|
||||
let webdog_path = self.build_path.join(WEBDOG_PATH);
|
||||
let webdog_path = self.build_path.join(
|
||||
self.site
|
||||
.config
|
||||
.webdog_path
|
||||
.clone()
|
||||
.unwrap_or_else(|| WEBDOG_DEFAULT_PATH.to_string()),
|
||||
);
|
||||
std::fs::create_dir(&webdog_path)?;
|
||||
std::fs::write(
|
||||
webdog_path.join("webdog.js"),
|
||||
|
|
|
@ -49,6 +49,8 @@ pub struct SiteConfig {
|
|||
pub sass_styles: Vec<PathBuf>,
|
||||
/// URL to the CDN used for the site's images.
|
||||
pub cdn_url: Url,
|
||||
/// The path to output webdog static resources to. Defaults to "webdog"
|
||||
pub webdog_path: Option<String>,
|
||||
/// The theme to use for the site's code blocks.
|
||||
/// TODO: dark/light themes
|
||||
/// TODO: export themes as CSS instead of styling HTML directly
|
||||
|
@ -73,6 +75,7 @@ impl SiteConfig {
|
|||
build: None,
|
||||
sass_styles: vec!["index.scss".into()],
|
||||
cdn_url,
|
||||
webdog_path: None,
|
||||
code_theme: "base16-ocean.dark".to_string(),
|
||||
resources: Default::default(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue