diff --git a/.gitignore b/.gitignore index f87a7e8..fd34989 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,3 @@ !/posts/README.md /cache /config.toml -/custom diff --git a/CONFIG.md b/CONFIG.md index cca2107..071dde9 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -24,8 +24,8 @@ link = "https://..." # public url of the blog, required if rss is enabled [dirs] posts = "posts" # where posts are stored media = "media" # directory served under /media/ -custom_templates = "custom/templates" # custom templates dir -custom_static = "custom/static" # custom static dir +custom_templates = "templates" # custom templates dir +custom_static = "static" # custom static dir # see CUSTOM.md for documentation [http] host = "0.0.0.0" # ip to listen on diff --git a/CUSTOM.md b/CUSTOM.md index 7b4b5a9..a9fcdcf 100644 --- a/CUSTOM.md +++ b/CUSTOM.md @@ -10,8 +10,8 @@ customizing the error page, other than CSS, is not supported at this time. ## Custom Templates -custom templates are loaded from `custom/templates` by default and they are -written in [Handlebars (the rust variant)](https://crates.io/crates/handlebars) +custom templates are written in +[Handlebars (the rust variant)](https://crates.io/crates/handlebars). the *custom templates directory* has a non-recursive structure: @@ -47,4 +47,3 @@ under `/static`. the endpoint `/media` is served from `dirs.media`. no other logic or mechanism is present. - diff --git a/src/config.rs b/src/config.rs index 4f9c42b..3fc6eb3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -126,8 +126,8 @@ impl Default for DirsConfig { Self { posts: "posts".into(), media: "media".into(), - custom_static: "custom/static".into(), - custom_templates: "custom/templates".into(), + custom_static: "static".into(), + custom_templates: "templates".into(), } } } diff --git a/src/main.rs b/src/main.rs index 5b4411a..03004c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -69,8 +69,8 @@ async fn main() -> eyre::Result<()> { let start = Instant::now(); // NOTE: use tokio::task::spawn_blocking if this ever turns into a concurrent task - let mut reg = - new_registry("custom/templates").context("failed to create handlebars registry")?; + let mut reg = new_registry(&config.dirs.custom_templates) + .context("failed to create handlebars registry")?; reg.register_helper("date", Box::new(helpers::date)); reg.register_helper("duration", Box::new(helpers::duration)); debug!(duration = ?start.elapsed(), "registered all templates"); @@ -88,8 +88,12 @@ async fn main() -> eyre::Result<()> { debug!("setting up watcher"); tasks.spawn( - watch_templates("custom/templates", watcher_token.clone(), reg) - .instrument(info_span!("custom_template_watcher")), + watch_templates( + config.dirs.custom_templates.clone(), + watcher_token.clone(), + reg, + ) + .instrument(info_span!("custom_template_watcher")), ); if config.cache.enable && config.cache.cleanup {