add hide
field in contact cards
This commit is contained in:
parent
fa4d0ba7e8
commit
e1448bd773
4 changed files with 24 additions and 38 deletions
|
@ -223,6 +223,7 @@ custom: Option<bool>
|
|||
user: "Option<String>"
|
||||
link: Option<String>
|
||||
newtab: Option<bool>
|
||||
hide: Option<bool>
|
||||
description: >
|
||||
Option<String>
|
||||
---
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use actix_web::{get, routes, web, HttpRequest, Responder};
|
||||
use cached::proc_macro::once;
|
||||
use glob::glob;
|
||||
use ramhorns::Content;
|
||||
|
||||
use crate::{
|
||||
|
@ -10,7 +9,7 @@ use crate::{
|
|||
markdown::File,
|
||||
metadata::MType,
|
||||
misc::{make_kw, read_file, Html},
|
||||
routes::contact::{find_links, remove_paragraphs},
|
||||
routes::contact::{find_links, read, remove_paragraphs},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -87,41 +86,9 @@ fn build_page(config: Config) -> String {
|
|||
// Get about
|
||||
let about = read_file(format!("{contacts_dir}/about.md"), MType::Generic);
|
||||
|
||||
let socials_dir = "socials";
|
||||
let mut socials = glob(&format!("{contacts_dir}/{socials_dir}/*{ext}"))
|
||||
.unwrap()
|
||||
.map(|e| {
|
||||
read_file(
|
||||
e.unwrap().to_string_lossy().to_string(),
|
||||
MType::Contact,
|
||||
)
|
||||
.unwrap()
|
||||
})
|
||||
.collect::<Vec<File>>();
|
||||
|
||||
let forges_dir = "forges";
|
||||
let mut forges = glob(&format!("{contacts_dir}/{forges_dir}/*{ext}"))
|
||||
.unwrap()
|
||||
.map(|e| {
|
||||
read_file(
|
||||
e.unwrap().to_string_lossy().to_string(),
|
||||
MType::Contact,
|
||||
)
|
||||
.unwrap()
|
||||
})
|
||||
.collect::<Vec<File>>();
|
||||
|
||||
let others_dir = "others";
|
||||
let mut others = glob(&format!("{contacts_dir}/{others_dir}/*{ext}"))
|
||||
.unwrap()
|
||||
.map(|e| {
|
||||
read_file(
|
||||
e.unwrap().to_string_lossy().to_string(),
|
||||
MType::Contact,
|
||||
)
|
||||
.unwrap()
|
||||
})
|
||||
.collect::<Vec<File>>();
|
||||
let mut socials = read(&format!("{contacts_dir}/socials/*{ext}"));
|
||||
let mut forges = read(&format!("{contacts_dir}/forges/*{ext}"));
|
||||
let mut others = read(&format!("{contacts_dir}/others/*{ext}"));
|
||||
|
||||
// Remove paragraphs in custom statements
|
||||
[&mut socials, &mut forges, &mut others]
|
||||
|
|
|
@ -46,6 +46,7 @@ pub struct FileMetadataContact {
|
|||
pub link: Option<String>,
|
||||
pub newtab: Option<bool>,
|
||||
pub description: Option<String>,
|
||||
pub hide: Option<bool>,
|
||||
}
|
||||
|
||||
/// Metadata for index page
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use cached::proc_macro::once;
|
||||
use glob::glob;
|
||||
use std::fs::read_to_string;
|
||||
|
||||
use crate::utils::markdown::File;
|
||||
use crate::utils::{markdown::File, metadata::MType, misc::read_file};
|
||||
|
||||
/// Contact node
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -48,3 +49,19 @@ pub fn remove_paragraphs(list: &mut [File]) {
|
|||
list.iter_mut()
|
||||
.for_each(|file| file.content = file.content.replace("<p>", "").replace("</p>", ""));
|
||||
}
|
||||
|
||||
pub fn read(path: &str) -> Vec<File> {
|
||||
glob(path)
|
||||
.unwrap()
|
||||
.map(|e| read_file(e.unwrap().to_string_lossy().to_string(), MType::Contact).unwrap())
|
||||
.filter(|f| {
|
||||
!f.metadata
|
||||
.info
|
||||
.contact
|
||||
.clone()
|
||||
.unwrap()
|
||||
.hide
|
||||
.unwrap_or_default()
|
||||
})
|
||||
.collect::<Vec<File>>()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue