feat(views): replace Home with Save as the default route
This commit is contained in:
@@ -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")]
|
||||
|
||||
@@ -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 {}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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 },
|
||||
|
||||
9
src/views/save.rs
Normal file
9
src/views/save.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use crate::components::EditQuote;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
#[component]
|
||||
pub fn Save() -> Element {
|
||||
rsx! {
|
||||
EditQuote {},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user