contact page

This commit is contained in:
2024-04-25 23:05:47 +02:00
parent 72c7c5d512
commit 76085120c1
6 changed files with 195 additions and 52 deletions

View File

@ -0,0 +1,87 @@
use askama::Template;
use axum::http::StatusCode;
use crate::components::{
site_footer::{render_site_footer, SiteFooter},
site_header::HeaderProps,
};
pub struct ContactLink {
pub href: String,
pub title: String,
pub label: String,
pub svg: String,
}
#[derive(Template)]
#[template(path = "contact.html")]
pub struct ContactPageTemplate {
pub title: String,
pub site_footer: SiteFooter,
pub header_props: HeaderProps,
pub links: Vec<ContactLink>,
}
pub async fn render_contact() -> Result<ContactPageTemplate, StatusCode> {
let site_footer = tokio::spawn(render_site_footer());
let site_footer = site_footer
.await
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
let links = vec![
ContactLink {
href: "mailto: michalvankosk@gmail.com".to_string(),
label: "michalvankosk@gmail.com".to_string(),
title: "E-mail address".to_string(),
svg: "mail".to_string(),
},
ContactLink {
href: "https://twitch.tv/michalvankodev".to_string(),
label: "Twitch".to_string(),
title: "Twitch channel".to_string(),
svg: "twitch".to_string(),
},
ContactLink {
href: "https://tiktok.com/@michalvankodev".to_string(),
label: "TikTok".to_string(),
title: "TikTok channel".to_string(),
svg: "tiktok".to_string(),
},
ContactLink {
href: "https://www.youtube.com/@michalvankodev".to_string(),
label: "YouTube".to_string(),
title: "YouTube channel".to_string(),
svg: "youtube".to_string(),
},
ContactLink {
href: "https://instagram.com/michalvankodev".to_string(),
label: "Instagram".to_string(),
title: "Instagram profile".to_string(),
svg: "instagram".to_string(),
},
ContactLink {
href: "https://instagram.com/michalvankodev".to_string(),
label: "GitHub".to_string(),
title: "Github profile".to_string(),
svg: "github".to_string(),
},
ContactLink {
href: "https://www.linkedin.com/in/michal-vanko-dev/".to_string(),
label: "LinkedIn".to_string(),
title: "LinkedIn profile".to_string(),
svg: "linkedin".to_string(),
},
ContactLink {
href: "https://discord.gg/2cGg7kwZEh".to_string(),
label: "Discord".to_string(),
title: "Discord channel".to_string(),
svg: "discord".to_string(),
},
];
Ok(ContactPageTemplate {
title: "Contact".to_owned(),
site_footer,
header_props: HeaderProps::default(),
links,
})
}

View File

@ -1,3 +1,4 @@
pub mod contact;
pub mod index;
pub mod post;
pub mod post_list;

View File

@ -1,6 +1,9 @@
use crate::{
feed::render_rss_feed,
pages::{index::render_index, post::render_post, post_list::render_post_list},
pages::{
contact::render_contact, index::render_index, post::render_post,
post_list::render_post_list,
},
};
use axum::{extract::MatchedPath, http::Request, routing::get, Router};
use tower_http::trace::TraceLayer;
@ -12,6 +15,7 @@ pub fn get_router() -> Router {
.route("/blog", get(render_post_list))
.route("/blog/tags/:tag", get(render_post_list))
.route("/blog/:post_id", get(render_post))
.route("/contact", get(render_contact))
.route("/feed.xml", get(render_rss_feed))
.layer(
TraceLayer::new_for_http().make_span_with(|request: &Request<_>| {