Add meta tags to blog posts
This commit is contained in:
parent
cb6e666a6e
commit
f7b850d62a
|
@ -447,14 +447,14 @@ where
|
|||
element_content_handlers: vec![element!("meta", |meta| {
|
||||
if let Some(attr) = meta.get_attribute("property") {
|
||||
let content = match attr.as_str() {
|
||||
"og:url" => &[env!("DOMAIN"), slug.as_ref()].concat(),
|
||||
"og:url" => &["https://", env!("DOMAIN"), slug.as_ref()].concat(),
|
||||
"og:type" => "article",
|
||||
"og:title" => title.as_ref(),
|
||||
"og:description" => description.as_ref(),
|
||||
"og:image" => {
|
||||
let image = image.as_ref();
|
||||
if !image.is_empty() {
|
||||
image
|
||||
&["https://", env!("DOMAIN"), image].concat()
|
||||
} else {
|
||||
meta.remove();
|
||||
""
|
||||
|
@ -516,8 +516,10 @@ where
|
|||
ContentType::Html,
|
||||
);
|
||||
Ok(())
|
||||
}), element!("head", |head| {
|
||||
head.append(&meta, ContentType::Html);
|
||||
Ok(())
|
||||
})],
|
||||
|
||||
..RewriteStrSettings::new()
|
||||
},
|
||||
)
|
||||
|
@ -769,12 +771,6 @@ where
|
|||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
// fn footer<S>(input: S) -> String
|
||||
// where
|
||||
// S: AsRef<str>,
|
||||
// {
|
||||
// }
|
||||
|
||||
pub(crate) fn sanitize<S: AsRef<str>>(input: S) -> String {
|
||||
rewrite_str(
|
||||
input.as_ref(),
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css" />
|
||||
</head>
|
||||
|
||||
|
|
Loading…
Reference in New Issue