2023-07-27 02:19:51 +00:00
|
|
|
#![allow(non_snake_case)]
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
use dioxus_router::prelude::*;
|
|
|
|
|
|
|
|
#[derive(Routable, Clone, PartialEq)]
|
|
|
|
enum Route {
|
|
|
|
#[layout(Nav)]
|
|
|
|
#[route("/")]
|
|
|
|
Homepage {},
|
|
|
|
|
|
|
|
#[route("/blog/:id")]
|
|
|
|
Blog { id: String },
|
|
|
|
}
|
|
|
|
|
2023-09-15 14:13:36 +00:00
|
|
|
#[component]
|
2023-07-27 02:19:51 +00:00
|
|
|
fn Homepage(cx: Scope) -> Element {
|
|
|
|
render! { h1 { "Welcome home" } }
|
|
|
|
}
|
|
|
|
|
2023-09-15 14:13:36 +00:00
|
|
|
#[component]
|
2023-07-27 02:19:51 +00:00
|
|
|
fn Blog(cx: Scope, id: String) -> Element {
|
|
|
|
render! {
|
|
|
|
h1 { "How to make: " }
|
|
|
|
p { "{id}" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-15 14:13:36 +00:00
|
|
|
#[component]
|
2023-07-27 02:19:51 +00:00
|
|
|
fn Nav(cx: Scope) -> Element {
|
|
|
|
render! {
|
|
|
|
nav {
|
|
|
|
li { Link { to: Route::Homepage { }, "Go home" } }
|
|
|
|
li { Link { to: Route::Blog { id: "Brownies".to_string() }, "Learn Brownies" } }
|
|
|
|
li { Link { to: Route::Blog { id: "Cookies".to_string() }, "Learn Cookies" } }
|
|
|
|
}
|
|
|
|
div { Outlet::<Route> {} }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
dioxus_desktop::launch(|cx| render!(Router::<Route> {}));
|
|
|
|
}
|