feat(views): replace Home with Save as the default route
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
// need dioxus
|
// need dioxus
|
||||||
use dioxus::prelude::*;
|
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.
|
/// Define a components module that contains all shared components for our app.
|
||||||
mod components;
|
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
|
// 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.
|
// many routes with a common UI like a navbar.
|
||||||
#[layout(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 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.
|
// the component for that route will be rendered. The component name that is rendered defaults to the variant name.
|
||||||
#[route("/")]
|
#[route("/save")]
|
||||||
Home {},
|
Save {},
|
||||||
// The route attribute can include dynamic parameters that implement [`std::str::FromStr`] and [`std::fmt::Display`] with the `:` syntax.
|
// 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`.
|
// In this case, id will match any integer like `/blog/123` or `/blog/-456`.
|
||||||
#[route("/blog/:id")]
|
#[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
|
//! 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.
|
//! a common wrapper around all child routes.
|
||||||
|
|
||||||
mod home;
|
mod save;
|
||||||
pub use home::Home;
|
pub use save::Save;
|
||||||
|
|
||||||
mod blog;
|
mod blog;
|
||||||
pub use blog::Blog;
|
pub use blog::Blog;
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ pub fn Navbar() -> Element {
|
|||||||
div {
|
div {
|
||||||
id: "navbar",
|
id: "navbar",
|
||||||
Link {
|
Link {
|
||||||
to: Route::Home {},
|
to: Route::Save {},
|
||||||
"Home"
|
"Save"
|
||||||
}
|
}
|
||||||
Link {
|
Link {
|
||||||
to: Route::Blog { id: 1 },
|
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