* improve documentation for the fullstack server context * Add a section about axum integration to the crate root docs * make serve_dioxus_application accept the cfg builder directly * remove unused server_fn module * improve fullstack config docs * improve documentation for the server function macro * fix axum router extension link * Fix doc tests * Fix launch builder * Simplify the launch builder * don't re-export launch in the prelude * refactor fullstack launch * Fix fullstack launch builder * Update static generation with the new builder api * fix some formatting/overly broad launch replacements * fix custom menu example * fix fullstack/static generation examples * Fix static generation launch * A few small formatting fixes * Fix a few doc tests * implement LaunchConfig for serve configs * fix fullstack launch with separate web and server launch methods * fix check with all features * dont expose inner core module * clippy and check * fix readme --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
71 lines
1.7 KiB
Rust
71 lines
1.7 KiB
Rust
//! You can use the `github_pages` method to set up a preset for github pages.
|
|
//! This will output your files in the `/docs` directory and set up a `404.html` file.
|
|
|
|
#![allow(unused)]
|
|
use dioxus::prelude::*;
|
|
|
|
// Generate all routes and output them to the static path
|
|
fn main() {
|
|
dioxus::LaunchBuilder::new()
|
|
.with_cfg(dioxus::static_site_generation::Config::new().github_pages())
|
|
.launch(|| {
|
|
rsx! {
|
|
Router::<Route> {}
|
|
}
|
|
});
|
|
}
|
|
|
|
#[derive(Clone, Routable, Debug, PartialEq)]
|
|
enum Route {
|
|
#[route("/")]
|
|
Home {},
|
|
|
|
#[route("/blog")]
|
|
Blog,
|
|
|
|
// You must include a catch all route to handle 404s
|
|
#[route("/:..route")]
|
|
PageNotFound { route: Vec<String> },
|
|
}
|
|
|
|
#[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 world!" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#[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!" }
|
|
}
|
|
}
|
|
}
|
|
|
|
#[component]
|
|
fn PageNotFound(route: Vec<String>) -> Element {
|
|
rsx! {
|
|
h1 { "Page not found" }
|
|
p { "We are terribly sorry, but the page you requested doesn't exist." }
|
|
pre { color: "red", "log:\nattempted to navigate to: {route:?}" }
|
|
}
|
|
}
|