mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-22 19:40:14 -04:00
Allow routing via regular path
This commit is contained in:
parent
ede08f7ef6
commit
6a916fac3c
@ -24,11 +24,11 @@ pub fn tabbed_view(state: TabState<G>) -> View<G> {
|
||||
header(class="no-print") {
|
||||
nav {
|
||||
ul {
|
||||
li { a(href="#plan", class="no-print") { "Plan" } " > "
|
||||
li { a(href="/ui/plan", class="no-print") { "Plan" } " > "
|
||||
}
|
||||
li { a(href="#inventory", class="no-print") { "Inventory" } " > "
|
||||
li { a(href="/ui/inventory", class="no-print") { "Inventory" } " > "
|
||||
}
|
||||
li { a(href="#cook", class="no-print") { "Cook" }
|
||||
li { a(href="/ui/cook", class="no-print") { "Cook" }
|
||||
}
|
||||
}
|
||||
ul {
|
||||
|
@ -15,7 +15,7 @@ use std::fmt::Debug;
|
||||
use std::rc::Rc;
|
||||
|
||||
use sycamore::prelude::*;
|
||||
use tracing::{debug, error, instrument};
|
||||
use tracing::{debug, error, info, instrument};
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::Event;
|
||||
@ -190,11 +190,12 @@ impl DeriveRoute for AppRoutes {
|
||||
#[instrument]
|
||||
fn from(input: &(String, String, String)) -> AppRoutes {
|
||||
debug!(origin=%input.0, path=%input.1, hash=%input.2, "routing");
|
||||
match input.2.as_str() {
|
||||
let (_origin, path, _hash) = input;
|
||||
let route = match path.as_str() {
|
||||
"" => AppRoutes::default(),
|
||||
"#plan" => AppRoutes::Plan,
|
||||
"#cook" => AppRoutes::Cook,
|
||||
"#inventory" => AppRoutes::Inventory,
|
||||
"/ui/plan" | "/" => AppRoutes::Plan,
|
||||
"/ui/ook" => AppRoutes::Cook,
|
||||
"/ui/inventory" => AppRoutes::Inventory,
|
||||
h => {
|
||||
// TODO(jwall): Parse the recipe hash
|
||||
let parts: Vec<&str> = h.splitn(2, "/").collect();
|
||||
@ -206,6 +207,8 @@ impl DeriveRoute for AppRoutes {
|
||||
error!(origin=%input.0, path=%input.1, hash=%input.2, "Path not found");
|
||||
AppRoutes::NotFound
|
||||
}
|
||||
}
|
||||
};
|
||||
info!(route=?route, "Route identified");
|
||||
route
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user