Configurable contact information

main
Pantonshire 3 years ago
parent fb09420915
commit 3086bf170f

@ -15,6 +15,7 @@ pub(crate) struct Config {
pub site: SiteConfig, pub site: SiteConfig,
pub rss: RssConfig, pub rss: RssConfig,
pub atom: AtomConfig, pub atom: AtomConfig,
pub contact: Vec<ContactConfig>,
} }
#[derive(Deserialize, Clone, Debug)] #[derive(Deserialize, Clone, Debug)]
@ -50,6 +51,13 @@ pub(crate) struct AtomConfig {
pub title: String, pub title: String,
} }
#[derive(Deserialize, Clone, Debug)]
pub(crate) struct ContactConfig {
pub name: String,
pub user: String,
pub url: Option<String>,
}
impl str::FromStr for Config { impl str::FromStr for Config {
type Err = toml::de::Error; type Err = toml::de::Error;

@ -1,10 +1,13 @@
use std::sync::Arc;
use axum::Extension;
use maud::html; use maud::html;
use crate::template; use crate::{template, Context};
use super::response::Html; use super::response::Html;
pub(super) async fn handle() -> Html { pub(super) async fn handle(Extension(context): Extension<Arc<Context>>) -> Html {
Html::new() Html::new()
.with_title_static("Contact") .with_title_static("Contact")
.with_crawler_permissive() .with_crawler_permissive()
@ -18,16 +21,15 @@ pub(super) async fn handle() -> Html {
"If you want to contact me, you can find me at:" "If you want to contact me, you can find me at:"
} }
ul { ul {
li { @for contact in &context.config().contact {
"Twitter: " li {
a href="https://twitter.com/pantonshire" { "@pantonshire" } (contact.name) ": "
} @if let Some(url) = contact.url.as_deref() {
li { a href=(url) { (contact.user) }
"Mastodon: " } @else {
a href="https://tech.lgbt/web/@pantonshire#" { "@pantonshire@tech.lgbt" } (contact.user)
} }
li { }
"Discord: pantonshire#2076"
} }
} }
} }

Loading…
Cancel
Save