diff --git a/src/routes/contact.rs b/src/routes/contact.rs index 77aba1d..5debdb9 100644 --- a/src/routes/contact.rs +++ b/src/routes/contact.rs @@ -13,6 +13,8 @@ use crate::{ template::{Infos, NavBar}, }; +const CONTACT_DIR: &str = "contacts"; + pub fn pages(cfg: &mut web::ServiceConfig) { // Here define the services used let routes = |route_path| { @@ -76,7 +78,7 @@ fn find_links(directory: String) -> Vec { #[get("/{service}/{scope}")] async fn service_redirection(config: web::Data, req: HttpRequest) -> impl Responder { let info = req.match_info(); - let link = find_links(format!("{}/contacts", config.locations.data_dir)) + let link = find_links(format!("{}/{}", config.locations.data_dir, CONTACT_DIR)) .iter() // Find requested service .filter(|&x| x.service == *info.query("service")) @@ -105,6 +107,7 @@ async fn service_redirection(config: web::Data, req: HttpRequest) -> imp #[derive(Content, Debug)] struct NetworksTemplate { navbar: NavBar, + about: Option, socials_exists: bool, socials: Vec, @@ -123,9 +126,15 @@ fn remove_paragraphs(list: &mut [File]) { #[once(time = 60)] fn build_page(config: Config) -> String { - let contacts_dir = format!("{}/contacts", config.locations.data_dir); + let contacts_dir = format!("{}/{}", config.locations.data_dir, CONTACT_DIR); let ext = ".md"; + // Get about + let about = read_file( + &format!("{}/about.md", contacts_dir), + TypeFileMetadata::Generic, + ); + let socials_dir = "socials"; let mut socials = glob(&format!("{contacts_dir}/{socials_dir}/*{ext}")) .unwrap() @@ -156,6 +165,8 @@ fn build_page(config: Config) -> String { contact: true, ..NavBar::default() }, + about, + socials_exists: !socials.is_empty(), socials, diff --git a/templates/contact/index.html b/templates/contact/index.html index cbd8e5e..870d82c 100644 --- a/templates/contact/index.html +++ b/templates/contact/index.html @@ -8,9 +8,8 @@
{{>navbar.html}}

Contact

-

Je suis présent relativement partout sur internet 😸

+ {{#data}}{{#about}} {{&content}} {{/about}} {{#socials_exists}} - {{#data}} {{#socials_exists}}

Réseaux sociaux

    {{#socials}} {{>contact/element.html}} {{/socials}}