diff --git a/site_test/404.html b/site_test/404.html new file mode 100644 index 0000000..d7c911a --- /dev/null +++ b/site_test/404.html @@ -0,0 +1,11 @@ +{% extends "default" %} + +{% block titlevariable %} +{% set title = "Not Found" %} +{% endblock %} + +{% block content -%} + +

404 Not Found

+ +{%- endblock %} diff --git a/src/generator/mod.rs b/src/generator/mod.rs index 72fe378..bf94fc8 100644 --- a/src/generator/mod.rs +++ b/src/generator/mod.rs @@ -2,6 +2,7 @@ mod archive; mod css; mod home; mod markdown; +mod not_found; mod posts; mod rss; mod static_files; @@ -66,6 +67,12 @@ fn make_graph(watcher: Rc>) -> anyhow::Result>) -> anyhow::Result, + default_template: Input, + watcher: &mut FileWatcher, +) -> Input<()> { + let path = content_path("404.html"); + let (templates, invalidate) = + builder.add_invalidatable_rule(AddTemplate::new("404", path.clone(), default_template)); + watcher.watch(path, move || invalidate.invalidate()); + + let void = builder.add_value(()); + let context = builder.add_rule(BuildTemplateContext::new( + "/404.html".into(), + void, + |_, _| {}, + )); + + let render = builder.add_rule(RenderTemplate { + name: "404", + output_path: "404.html".into(), + templates, + context, + }); + + render +} diff --git a/src/live_reload.rs b/src/live_reload.rs index 0dc79e3..c7c27ea 100644 --- a/src/live_reload.rs +++ b/src/live_reload.rs @@ -35,7 +35,7 @@ pub async fn handle( Ok(response.map(|b| b.map_err(|_: Infallible| unreachable!()).boxed_unsync())) } else { let fallback_resp = fallback.call(request).await?; - Ok(Response::new(fallback_resp.boxed_unsync())) + Ok(fallback_resp.map(|b| b.boxed_unsync())) } }