Better Static Asset serving and fix extra header

This commit is contained in:
Jeremy Wall 2022-10-27 19:27:39 -04:00
parent 5f4b7c3f02
commit 40b6625620
2 changed files with 11 additions and 10 deletions

View File

@ -69,16 +69,18 @@ async fn ui_static_assets(Path(path): Path<String>) -> impl IntoResponse {
info!("Serving ui path"); info!("Serving ui path");
let mut path = path.trim_start_matches("/"); let mut path = path.trim_start_matches("/");
path = match path { if UiAssets::get(path).is_none() {
"" | "inventory" | "plan" | "cook" | "categories" | "login" => "index.html", path = match path {
_ => { "" | "inventory" | "plan" | "cook" | "categories" | "login" => "index.html",
if path.starts_with("recipe") { _ => {
"index.html" if path.starts_with("recipe") {
} else { "index.html"
path } else {
path
}
} }
} };
}; }
debug!(path = path, "Serving transformed path"); debug!(path = path, "Serving transformed path");
StaticFile(path.to_owned()) StaticFile(path.to_owned())
} }

View File

@ -67,7 +67,6 @@ pub fn UI<G: Html>(cx: Scope) -> View<G> {
}; };
view.set(view! { cx, view.set(view! { cx,
div(class="app") { div(class="app") {
Header()
Router(RouterProps { Router(RouterProps {
route: Routes::Plan, route: Routes::Plan,
route_select: route_switch, route_select: route_switch,