From 1bd70c4eb24a7cb9655e1c2ba859fcbd65743c0c Mon Sep 17 00:00:00 2001 From: darkicewolf50 Date: Tue, 20 May 2025 17:44:02 -0600 Subject: [PATCH] feat(dioxus): added meta tags to most pages, except the blog page-asaddsasd --- src/helper_fun.rs | 9 +++++++++ src/lib.rs | 3 +++ src/views/blog.rs | 6 +++++- src/views/contact_me.rs | 6 +++++- src/views/home.rs | 8 ++++++++ src/views/projects.rs | 6 +++++- 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/helper_fun.rs b/src/helper_fun.rs index 4a1d29c..b5b13c3 100644 --- a/src/helper_fun.rs +++ b/src/helper_fun.rs @@ -9,6 +9,15 @@ pub fn get_tech_logos_from_str(used_tech: &'static str) -> Element { } } +#[component] +pub fn set_meta_tags(description: &'static str, keywords: &'static str) -> Element { + rsx! { + document::Meta { name: "description", content: description } + document::Meta { name: "keywords", content: keywords } + document::Meta { name: "author", content: "Brock Tomlinson" } + } +} + #[derive(PartialEq, Props, Clone, Copy)] pub struct TechDes { pub tech_name: &'static str, diff --git a/src/lib.rs b/src/lib.rs index b40b3ba..60dccf8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ use dioxus::prelude::*; +pub use helper_fun::set_meta_tags; // use components::Hero; use views::{Blog, Blogs, ContactMe, Home, Navbar, NewHome, Projects}; @@ -53,6 +54,8 @@ pub enum Route { fn PageNotFound(route: Vec) -> Element { rsx! { document::Stylesheet { href: asset!("/assets/styling/notFound.css") } + document::Title { "Brock Tomlinson - Not Found" } + set_meta_tags { description: "This is not a valid page", keywords: "404 Nothing" } div { id: "not-found", h1 { "Page not found" } p { "We are terribly sorry, but the page you requested doesn't exist." } diff --git a/src/views/blog.rs b/src/views/blog.rs index d22c4fb..ea6c0ee 100644 --- a/src/views/blog.rs +++ b/src/views/blog.rs @@ -1,4 +1,4 @@ -use crate::Route; +use crate::{set_meta_tags, Route}; use dioxus::{logger::tracing, prelude::*}; use reqwest; use serde::{Deserialize, Serialize}; @@ -93,6 +93,10 @@ pub fn Blogs(page_num: u32) -> Element { document::Stylesheet { href: asset!("/assets/styling/blog.css") } div { id: "blogs", document::Title { "Brock Tomlinson - Blogs" } + set_meta_tags { + description: "This is a collection of blog posts, ranging from tutorials, technologies I found interesting, and opinion pieces", + keywords: "blogs blog software engineer webdev", + } div { id: "blogs-title", h1 { "Blogs" } p { diff --git a/src/views/contact_me.rs b/src/views/contact_me.rs index 13ec323..f7b0bae 100644 --- a/src/views/contact_me.rs +++ b/src/views/contact_me.rs @@ -4,7 +4,7 @@ use serde_json; // use dioxus::logger::tracing; use dioxus::prelude::*; -use crate::views::Contact; +use crate::{helper_fun::set_meta_tags, views::Contact}; #[component] pub fn ContactMe() -> Element { @@ -17,6 +17,10 @@ pub fn ContactMe() -> Element { rsx! { document::Stylesheet { href: asset!("/assets/styling/contactme.css") } document::Title { "Brock Tomlinson - Contact" } + set_meta_tags { + description: "Get in Touch, get in contact", + keywords: "contact software engineer webdev", + } div { id: "ContactMe", div { h2 { "Get in Touch" } diff --git a/src/views/home.rs b/src/views/home.rs index 704a601..0316c7a 100644 --- a/src/views/home.rs +++ b/src/views/home.rs @@ -1,4 +1,5 @@ use crate::components::{Experience, TechCat}; +use crate::helper_fun::set_meta_tags; use crate::views::{Contact, Projects}; use crate::Route; use dioxus::prelude::*; @@ -32,6 +33,13 @@ pub fn Home() -> Element { rsx!( document::Title { "Brock Tomlinson - Home" } document::Stylesheet { href: asset!("/assets/styling/home.css") } + set_meta_tags { + description: "a fourth year Software Engineering Student specializing in full-stack development with a strong focus on backend technologies. + I am developing the language of how to design, develop, and create programs that are to industry standards and reasonably efficent. + I bring the lessons learned from each project I have completed, + learning from the mistakes I have made and bringing improved versions forward into the next project.", + keywords: "dev webdev Rust rust-lang software engineer", + } div { div { id: "home-intro", h1 { "Hi I'm Brock" } diff --git a/src/views/projects.rs b/src/views/projects.rs index fee7e3f..d3e8bbf 100644 --- a/src/views/projects.rs +++ b/src/views/projects.rs @@ -1,4 +1,4 @@ -use crate::helper_fun::get_tech_logos_from_str; +use crate::helper_fun::{get_tech_logos_from_str, set_meta_tags}; use dioxus::prelude::*; #[component] @@ -6,6 +6,10 @@ pub fn Projects(#[props(default = true)] independent_page: bool) -> Element { rsx! { if independent_page { document::Title { "Brock Tomlinson - Projects" } + set_meta_tags { + description: "Top Featured and Recent Projects", + keywords: "projects Rust CSS HTML JavaScript Dioxus Gitea Git software engineer", + } } div { h2 { "Projects" }