feat: router crate is polished up

This commit is contained in:
Jonathan Kelley committed 2022-03-04 13:16:37 -05:00
1 parent 60b11081f2
commit cc83900334
12 files changed
+341 -260

No files matched your search

+6 -1
View File
@@ -24,6 +24,8 @@ fn app(cx: Scope) -> Element {
Route { to: "/", Home {} }
Route { to: "/blog/", BlogList {} }
Route { to: "/blog/:id/", BlogPost {} }
Route { to: "/oranges", "Oranges are not apples!" }
Redirect { from: "/apples", to: "/oranges" }
}
})
}
@@ -41,6 +43,9 @@ fn BlogList(cx: Scope) -> Element {
}
fn BlogPost(cx: Scope) -> Element {
let id = use_route(&cx).segment::<usize>("id")?;
let id = use_route(&cx).segment("id")?;
log::debug!("rendering blog post {}", id);
cx.render(rsx! { div { "{id:?}" } })
}