diff --git a/Cargo.lock b/Cargo.lock index 50d6476..259b8c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,6 +116,7 @@ name = "frontend" version = "0.1.0" dependencies = [ "yew", + "yew-router", ] [[package]] @@ -259,6 +260,7 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d5564e570a38b43d78bdc063374a0c3098c4f0d64005b12f9bbe87e869b6d7" dependencies = [ + "futures-channel", "gloo-events", "js-sys", "wasm-bindgen", @@ -333,6 +335,8 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" dependencies = [ + "futures-channel", + "futures-core", "js-sys", "wasm-bindgen", ] @@ -594,6 +598,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "route-recognizer" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afab94fb28594581f62d981211a9a4d53cc8130bbcbbb89a0440d9b8e81a7746" + [[package]] name = "rustc-demangle" version = "0.1.23" @@ -897,3 +907,32 @@ dependencies = [ "quote", "syn 1.0.109", ] + +[[package]] +name = "yew-router" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "426ee0486d2572a6c5e39fbdbc48b58d59bb555f3326f54631025266cf04146e" +dependencies = [ + "gloo", + "js-sys", + "route-recognizer", + "serde", + "serde_urlencoded", + "tracing", + "wasm-bindgen", + "web-sys", + "yew", + "yew-router-macro", +] + +[[package]] +name = "yew-router-macro" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b249cdb39e0cddaf0644dedc781854524374664793479fdc01e6a65d6e6ae3" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] diff --git a/Cargo.toml b/Cargo.toml index 40e92ff..04cf285 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,4 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -yew = { version = "0.20.0", features = ["csr"] } \ No newline at end of file +yew = { version = "0.20.0", features = ["csr"] } +yew-router = "0.17.0" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 14064c1..c5d7795 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,45 @@ mod topbar; use yew::prelude::*; +use yew_router::prelude::*; use topbar::TopBar; +#[derive(Clone, Routable, PartialEq)] +enum Route { + #[at("/")] + Home, + #[at("/services")] + Services, + #[at("/community")] + Community, + #[at("/about")] + About, + #[not_found] + #[at("/404")] + NotFound, +} + +fn switch(routes: Route) -> Html { + match routes { + Route::Home => html! {