Configurable contact information
This commit is contained in:
1 parent
fb09420915
commit
3086bf170f
2 files changed
+22
-12
No files matched your search
@@ -15,6 +15,7 @@ pub(crate) struct Config {
|
||||
pub site: SiteConfig,
|
||||
pub rss: RssConfig,
|
||||
pub atom: AtomConfig,
|
||||
pub contact: Vec<ContactConfig>,
|
||||
}
|
||||
|
||||
#[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<String>,
|
||||
}
|
||||
|
||||
impl str::FromStr for Config {
|
||||
type Err = toml::de::Error;
|
||||
|
||||
|
||||
@@ -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<Arc<Context>>) -> 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user