From b989dc06d7956d3ecc79686b94bed7f29117d05f Mon Sep 17 00:00:00 2001 From: antifallobst Date: Fri, 13 Oct 2023 18:20:18 +0200 Subject: [PATCH] feat: added profile routing --- src/content/mod.rs | 3 ++- src/content/profile/mod.rs | 13 +++++++++++++ src/main.rs | 5 ++++- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/content/profile/mod.rs diff --git a/src/content/mod.rs b/src/content/mod.rs index caa9ce4..864faf8 100644 --- a/src/content/mod.rs +++ b/src/content/mod.rs @@ -1,3 +1,4 @@ pub mod about; +pub mod error; pub mod home; -pub mod error; \ No newline at end of file +pub mod profile; diff --git a/src/content/profile/mod.rs b/src/content/profile/mod.rs new file mode 100644 index 0000000..b62aef0 --- /dev/null +++ b/src/content/profile/mod.rs @@ -0,0 +1,13 @@ +use yew::prelude::*; + +#[derive(PartialEq, Properties)] +pub struct Props { + pub username: AttrValue, +} + +#[function_component] +pub fn Profile(props: &Props) -> Html { + html! { +

{"User profile: "}{props.username.clone()}

+ } +} diff --git a/src/main.rs b/src/main.rs index 88f72b0..89ba8a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ mod content; mod topbar; use backend::Session; -use content::{about::About, error, home::Home}; +use content::{about::About, error, home::Home, profile::Profile}; use gloo::dialogs::alert; use gloo_storage::{SessionStorage, Storage}; use std::ops::Deref; @@ -21,6 +21,8 @@ enum Route { Community, #[at("/about")] About, + #[at("/profile/:username")] + Profile { username: String }, #[not_found] #[at("/404")] NotFound, @@ -32,6 +34,7 @@ fn switch(routes: Route) -> Html { Route::Services => html! {

{ "Services" }

}, Route::Community => html! {

{ "Community" }

}, Route::About => html! {}, + Route::Profile { username } => html! { }, Route::NotFound => html! { }, } }