add quotes when possible, trailing space at the end
All checks were successful
ci/woodpecker/push/publish Pipeline was successful

This commit is contained in:
Mylloon 2023-04-29 15:00:06 +02:00
parent 24f46402d8
commit 8d5dc03406
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 15 additions and 10 deletions

View file

@ -39,6 +39,11 @@ struct Data<T> {
data: T,
}
/// Add quotes around a string
fn add_quotes(string: String) -> String {
format!("\"{}\"", string)
}
impl Template {
pub fn render<C: Content>(&self, template: &str, data: C, info: Infos) -> String {
let mut templates: Ramhorns = Ramhorns::lazy(&self.directory).unwrap();
@ -47,9 +52,9 @@ impl Template {
tplt.render(&Data {
app_name: self.app_name.to_owned(),
page_title: info.page_title,
page_desc: info.page_desc,
page_kw: info.page_kw,
url: info.url,
page_desc: info.page_desc.map(add_quotes),
page_kw: info.page_kw.map(add_quotes),
url: add_quotes(info.url),
data,
})
}

View file

@ -2,22 +2,22 @@
{{#page_title}}
<meta name="title" content="{{page_title}} " />
{{/page_title}} {{#page_desc}}
<meta name="description" content="{{page_desc}} " />
<meta name="description" content="{{&page_desc}}" />
{{/page_desc}} {{#page_kw}}
<meta name="keywords" content="{{page_kw}} " />
<meta name="keywords" content="{{&page_kw}}" />
{{/page_kw}}
<meta name="author" content="Mylloon" />
<!-- Open Graph -->
<meta property="og:title" content="{{page_title}} " />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{url}} " />
<meta property="og:description" content="{{&page_desc}}" />
<meta property="og:url" content="{{&url}}" />
<meta property="og:image" content="/icons/apple-touch-icon.png" />
<meta property="og:description" content="{{page_desc}} " />
<meta property="og:type" content="website" />
<meta name="theme-color" content="#43B581" />
<!-- Twitter -->
<meta property="twitter:url" content="{{url}} " />
<meta property="twitter:title" content="{{page_title}} " />
<meta property="twitter:description" content="{{page_desc}} " />
<meta property="twitter:description" content="{{&page_desc}}" />
<meta property="twitter:url" content="{{&url}}" />
<meta property="twitter:image" content="/icons/apple-touch-icon.png" />