diff --git a/src/main.rs b/src/main.rs index eb96a99..36ee80a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ // need dioxus use dioxus::prelude::*; -use views::{Blog, Home, Navbar}; +use views::{Blog, Navbar, Save}; /// Define a components module that contains all shared components for our app. mod components; @@ -20,10 +20,11 @@ enum Route { // The layout attribute defines a wrapper for all routes under the layout. Layouts are great for wrapping // many routes with a common UI like a navbar. #[layout(Navbar)] + #[redirect("/", || Route::Save {})] // The route attribute defines the URL pattern that a specific route matches. If that pattern matches the URL, // the component for that route will be rendered. The component name that is rendered defaults to the variant name. - #[route("/")] - Home {}, + #[route("/save")] + Save {}, // The route attribute can include dynamic parameters that implement [`std::str::FromStr`] and [`std::fmt::Display`] with the `:` syntax. // In this case, id will match any integer like `/blog/123` or `/blog/-456`. #[route("/blog/:id")] diff --git a/src/views/home.rs b/src/views/home.rs deleted file mode 100644 index 686ce7d..0000000 --- a/src/views/home.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::components::{Echo, Hero}; -use dioxus::prelude::*; - -/// The Home page component that will be rendered when the current route is `[Route::Home]` -#[component] -pub fn Home() -> Element { - rsx! { - Hero {} - Echo {} - } -} diff --git a/src/views/mod.rs b/src/views/mod.rs index 0a41003..abc5fcd 100644 --- a/src/views/mod.rs +++ b/src/views/mod.rs @@ -8,8 +8,8 @@ //! The [`Navbar`] component will be rendered on all pages of our app since every page is under the layout. The layout defines //! a common wrapper around all child routes. -mod home; -pub use home::Home; +mod save; +pub use save::Save; mod blog; pub use blog::Blog; diff --git a/src/views/navbar.rs b/src/views/navbar.rs index 1b13536..b9ddbaf 100644 --- a/src/views/navbar.rs +++ b/src/views/navbar.rs @@ -16,8 +16,8 @@ pub fn Navbar() -> Element { div { id: "navbar", Link { - to: Route::Home {}, - "Home" + to: Route::Save {}, + "Save" } Link { to: Route::Blog { id: 1 }, diff --git a/src/views/save.rs b/src/views/save.rs new file mode 100644 index 0000000..3718c0c --- /dev/null +++ b/src/views/save.rs @@ -0,0 +1,9 @@ +use crate::components::EditQuote; +use dioxus::prelude::*; + +#[component] +pub fn Save() -> Element { + rsx! { + EditQuote {}, + } +}