diff --git a/src/bin/blog_server/config.rs b/src/bin/blog_server/config.rs index d2c194e..07745c0 100644 --- a/src/bin/blog_server/config.rs +++ b/src/bin/blog_server/config.rs @@ -15,6 +15,7 @@ pub(crate) struct Config { pub site: SiteConfig, pub rss: RssConfig, pub atom: AtomConfig, + pub contact: Vec, } #[derive(Deserialize, Clone, Debug)] @@ -50,6 +51,13 @@ pub(crate) struct AtomConfig { pub title: String, } +#[derive(Deserialize, Clone, Debug)] +pub(crate) struct ContactConfig { + pub name: String, + pub user: String, + pub url: Option, +} + impl str::FromStr for Config { type Err = toml::de::Error; diff --git a/src/bin/blog_server/service/contact.rs b/src/bin/blog_server/service/contact.rs index d562c80..bed2ebf 100644 --- a/src/bin/blog_server/service/contact.rs +++ b/src/bin/blog_server/service/contact.rs @@ -1,10 +1,13 @@ +use std::sync::Arc; + +use axum::Extension; use maud::html; -use crate::template; +use crate::{template, Context}; use super::response::Html; -pub(super) async fn handle() -> Html { +pub(super) async fn handle(Extension(context): Extension>) -> Html { Html::new() .with_title_static("Contact") .with_crawler_permissive() @@ -18,16 +21,15 @@ pub(super) async fn handle() -> Html { "If you want to contact me, you can find me at:" } ul { - li { - "Twitter: " - a href="https://twitter.com/pantonshire" { "@pantonshire" } - } - li { - "Mastodon: " - a href="https://tech.lgbt/web/@pantonshire#" { "@pantonshire@tech.lgbt" } - } - li { - "Discord: pantonshire#2076" + @for contact in &context.config().contact { + li { + (contact.name) ": " + @if let Some(url) = contact.url.as_deref() { + a href=(url) { (contact.user) } + } @else { + (contact.user) + } + } } } }