refactor
This commit is contained in:
parent
fe0ccd913c
commit
73b059b155
3 changed files with 10 additions and 5 deletions
|
@ -21,3 +21,8 @@ pub fn get_url(fc: FileConfig) -> String {
|
|||
|
||||
format!("{}://{}", fc.scheme.unwrap(), fc.domain.unwrap())
|
||||
}
|
||||
|
||||
/// Make a list of keywords
|
||||
pub fn make_kw(list: &[&str]) -> Option<String> {
|
||||
Some(list.join(", "))
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ use crate::{
|
|||
markdown::{
|
||||
get_metadata, get_options, read_file, File, FileMetadataBlog, TypeFileMetadata,
|
||||
},
|
||||
utils::get_url,
|
||||
utils::{get_url, make_kw},
|
||||
},
|
||||
template::{Infos, NavBar},
|
||||
};
|
||||
|
@ -64,7 +64,7 @@ fn build_index(config: Config) -> String {
|
|||
"Liste des posts d'{}",
|
||||
config.fc.name.unwrap_or_default()
|
||||
)),
|
||||
page_kw: Some(["blog", "blogging"].join(", ")),
|
||||
page_kw: make_kw(&["blog", "blogging"]),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -37,14 +37,14 @@ pub struct NavBar {
|
|||
struct Data<T> {
|
||||
/// App name
|
||||
app_name: String,
|
||||
/// App URL
|
||||
url: String,
|
||||
/// Title of the page
|
||||
page_title: Option<String>,
|
||||
/// Description of the page
|
||||
page_desc: Option<String>,
|
||||
/// Keywords of the the page
|
||||
page_kw: Option<String>,
|
||||
/// App URL
|
||||
url: String,
|
||||
/// Data needed to render the page
|
||||
data: T,
|
||||
}
|
||||
|
@ -61,10 +61,10 @@ impl Template {
|
|||
|
||||
tplt.render(&Data {
|
||||
app_name: self.app_name.to_owned(),
|
||||
url: add_quotes(self.url.to_owned()),
|
||||
page_title: info.page_title,
|
||||
page_desc: info.page_desc.map(add_quotes),
|
||||
page_kw: info.page_kw.map(add_quotes),
|
||||
url: add_quotes(self.url.to_owned()),
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue