123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- //! Static generation works out of the box with the router. Just add a router anywhere in your app and it will generate any static routes for you!
- #![allow(unused)]
- use dioxus::prelude::*;
- // Generate all routes and output them to the static path
- fn main() {
- launch(|| {
- rsx! {
- Router::<Route> {}
- }
- });
- }
- #[derive(Clone, Routable, Debug, PartialEq)]
- enum Route {
- #[route("/")]
- Home {},
- #[route("/blog")]
- Blog,
- }
- #[component]
- fn Blog() -> Element {
- rsx! {
- Link { to: Route::Home {}, "Go to counter" }
- table {
- tbody {
- for _ in 0..100 {
- tr {
- for _ in 0..100 {
- td { "hello!" }
- }
- }
- }
- }
- }
- }
- }
- #[component]
- fn Home() -> Element {
- let mut count = use_signal(|| 0);
- rsx! {
- Link { to: Route::Blog {}, "Go to blog" }
- div {
- h1 { "High-Five counter: {count}" }
- button { onclick: move |_| count += 1, "Up high!" }
- button { onclick: move |_| count -= 1, "Down low!" }
- }
- }
- }
|