mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-26 22:20:19 +00:00
59 lines
1.1 KiB
Rust
59 lines
1.1 KiB
Rust
#![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 },
|
|
}
|
|
|
|
#[component]
|
|
fn Homepage() -> Element {
|
|
rsx! { h1 { "Welcome home" } }
|
|
}
|
|
|
|
#[component]
|
|
fn Blog(id: String) -> Element {
|
|
rsx! {
|
|
h1 { "How to make: " }
|
|
p { "{id}" }
|
|
}
|
|
}
|
|
|
|
#[component]
|
|
fn Nav() -> Element {
|
|
rsx! {
|
|
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() {
|
|
launch_desktop(|| rsx! { Router::<Route> {} });
|
|
}
|