This commit is contained in:
Mylloon 2023-10-24 11:57:50 +02:00
parent fe0ccd913c
commit 73b059b155
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 10 additions and 5 deletions

View file

@ -21,3 +21,8 @@ pub fn get_url(fc: FileConfig) -> String {
format!("{}://{}", fc.scheme.unwrap(), fc.domain.unwrap()) format!("{}://{}", fc.scheme.unwrap(), fc.domain.unwrap())
} }
/// Make a list of keywords
pub fn make_kw(list: &[&str]) -> Option<String> {
Some(list.join(", "))
}

View file

@ -21,7 +21,7 @@ use crate::{
markdown::{ markdown::{
get_metadata, get_options, read_file, File, FileMetadataBlog, TypeFileMetadata, get_metadata, get_options, read_file, File, FileMetadataBlog, TypeFileMetadata,
}, },
utils::get_url, utils::{get_url, make_kw},
}, },
template::{Infos, NavBar}, template::{Infos, NavBar},
}; };
@ -64,7 +64,7 @@ fn build_index(config: Config) -> String {
"Liste des posts d'{}", "Liste des posts d'{}",
config.fc.name.unwrap_or_default() config.fc.name.unwrap_or_default()
)), )),
page_kw: Some(["blog", "blogging"].join(", ")), page_kw: make_kw(&["blog", "blogging"]),
}, },
) )
} }

View file

@ -37,14 +37,14 @@ pub struct NavBar {
struct Data<T> { struct Data<T> {
/// App name /// App name
app_name: String, app_name: String,
/// App URL
url: String,
/// Title of the page /// Title of the page
page_title: Option<String>, page_title: Option<String>,
/// Description of the page /// Description of the page
page_desc: Option<String>, page_desc: Option<String>,
/// Keywords of the the page /// Keywords of the the page
page_kw: Option<String>, page_kw: Option<String>,
/// App URL
url: String,
/// Data needed to render the page /// Data needed to render the page
data: T, data: T,
} }
@ -61,10 +61,10 @@ impl Template {
tplt.render(&Data { tplt.render(&Data {
app_name: self.app_name.to_owned(), app_name: self.app_name.to_owned(),
url: add_quotes(self.url.to_owned()),
page_title: info.page_title, page_title: info.page_title,
page_desc: info.page_desc.map(add_quotes), page_desc: info.page_desc.map(add_quotes),
page_kw: info.page_kw.map(add_quotes), page_kw: info.page_kw.map(add_quotes),
url: add_quotes(self.url.to_owned()),
data, data,
}) })
} }