aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs24
-rw-r--r--src/tmpl/mod.rs8
2 files changed, 9 insertions, 23 deletions
diff --git a/src/main.rs b/src/main.rs
index 737ab45..3952975 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,6 +10,7 @@ use axum::{
routing::{get, get_service},
Router,
};
+use axum_extra::routing::SpaRouter;
use color_eyre::eyre::Result;
use hyper::StatusCode;
use prometheus::{Encoder, TextEncoder};
@@ -104,6 +105,8 @@ async fn main() -> Result<()> {
))
.layer(CorsLayer::permissive());
+ let files = SpaRouter::new("/static", "static");
+
let app = Router::new()
// meta
.route("/.within/health", get(healthcheck))
@@ -194,25 +197,8 @@ async fn main() -> Result<()> {
// junk google wants
.route("/sitemap.xml", get(handlers::feeds::sitemap))
// static files
- .nest(
- "/css",
- get_service(ServeDir::new("./css")).handle_error(|err: io::Error| async move {
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- format!("unhandled internal server error: {}", err),
- )
- }),
- )
- .nest(
- "/static",
- get_service(ServeDir::new("./static")).handle_error(|err: io::Error| async move {
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- format!("unhandled internal server error: {}", err),
- )
- }),
- )
- .fallback(handlers::not_found.into_service())
+ .merge(files)
+ .fallback(handlers::not_found)
.layer(middleware);
#[cfg(target_os = "linux")]
diff --git a/src/tmpl/mod.rs b/src/tmpl/mod.rs
index 79b8196..1fbb239 100644
--- a/src/tmpl/mod.rs
+++ b/src/tmpl/mod.rs
@@ -27,12 +27,12 @@ pub fn base(title: Option<&str>, styles: Option<&str>, content: Markup) -> Marku
}
}
meta name="viewport" content="width=device-width, initial-scale=1.0";
- link rel="stylesheet" href={"/css/hack.css?bustCache=" (*CACHEBUSTER)};
- link rel="stylesheet" href={"/css/gruvbox-dark.css?bustCache=" (*CACHEBUSTER)};
- link rel="stylesheet" href={"/css/shim.css?bustCache=" (*CACHEBUSTER)};
+ link rel="stylesheet" href={"/static/css/hack.css?bustCache=" (*CACHEBUSTER)};
+ link rel="stylesheet" href={"/static/css/gruvbox-dark.css?bustCache=" (*CACHEBUSTER)};
+ link rel="stylesheet" href={"/static/css/shim.css?bustCache=" (*CACHEBUSTER)};
@match now.month() {
12|1|2 => {
- link rel="stylesheet" href={"/css/snow.css?bustCache=" (*CACHEBUSTER)};
+ link rel="stylesheet" href={"/static/css/snow.css?bustCache=" (*CACHEBUSTER)};
}
_ => {},
}