From 68814cdd207ac34c1b8c35c097545fe6188449f0 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 24 Oct 2023 12:21:30 +0200 Subject: [PATCH] fix metadata? --- src/config.rs | 1 + src/template.rs | 16 ++++++++-------- templates/metadata.html | 29 +++++++++++++++-------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/config.rs b/src/config.rs index 7f2fce0..d269712 100644 --- a/src/config.rs +++ b/src/config.rs @@ -115,6 +115,7 @@ pub fn get_config(file_path: &str) -> Config { directory: format!("{}/{}", files_root, templates_dir), app_name: internal_config.app_name.unwrap(), url: internal_config.domain.unwrap(), + name: internal_config.name, }, } } diff --git a/src/template.rs b/src/template.rs index 7d5f083..e7f873a 100644 --- a/src/template.rs +++ b/src/template.rs @@ -9,6 +9,8 @@ pub struct Template { pub app_name: String, /// URL of app pub url: String, + /// Name of user + pub name: Option, } /// Structure used by /routes/*.rs @@ -45,15 +47,12 @@ struct Data { page_desc: Option, /// Keywords of the the page page_kw: Option, + /// Author's name + page_author: Option, /// Data needed to render the page data: T, } -/// Add quotes around a string -fn add_quotes(string: String) -> String { - format!("\"{}\"", string) -} - impl Template { pub fn render(&self, template: &str, data: C, info: Infos) -> String { let mut templates: Ramhorns = Ramhorns::lazy(&self.directory).unwrap(); @@ -61,10 +60,11 @@ impl Template { tplt.render(&Data { app_name: self.app_name.to_owned(), - url: add_quotes(self.url.to_owned()), + url: 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), + page_desc: info.page_desc, + page_kw: info.page_kw, + page_author: self.name.clone(), data, }) } diff --git a/templates/metadata.html b/templates/metadata.html index f8315ac..ca6c09a 100644 --- a/templates/metadata.html +++ b/templates/metadata.html @@ -2,28 +2,29 @@ {{#page_title}} {{/page_title}} {{#page_desc}} - - + {{/page_desc}} {{#page_kw}} - - -{{/page_kw}} - + +{{/page_kw}} {{#page_author}} + +{{/page_author}} +{{#page_title}} - - - - +{{/page_title}} {{#page_desc}} + +{{/page_desc}} + +{{#page_title}} - - - - +{{/page_title}} {{#page_desc}} + +{{/page_desc}} +