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| {
|
element_content_handlers: vec![element!("meta", |meta| {
|
||||||
if let Some(attr) = meta.get_attribute("property") {
|
if let Some(attr) = meta.get_attribute("property") {
|
||||||
let content = match attr.as_str() {
|
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:type" => "article",
|
||||||
"og:title" => title.as_ref(),
|
"og:title" => title.as_ref(),
|
||||||
"og:description" => description.as_ref(),
|
"og:description" => description.as_ref(),
|
||||||
"og:image" => {
|
"og:image" => {
|
||||||
let image = image.as_ref();
|
let image = image.as_ref();
|
||||||
if !image.is_empty() {
|
if !image.is_empty() {
|
||||||
image
|
&["https://", env!("DOMAIN"), image].concat()
|
||||||
} else {
|
} else {
|
||||||
meta.remove();
|
meta.remove();
|
||||||
""
|
""
|
||||||
|
@ -516,8 +516,10 @@ where
|
||||||
ContentType::Html,
|
ContentType::Html,
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
}), element!("head", |head| {
|
||||||
|
head.append(&meta, ContentType::Html);
|
||||||
|
Ok(())
|
||||||
})],
|
})],
|
||||||
|
|
||||||
..RewriteStrSettings::new()
|
..RewriteStrSettings::new()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -754,7 +756,7 @@ where
|
||||||
element_content_handlers: vec![element!("a", move |t| {
|
element_content_handlers: vec![element!("a", move |t| {
|
||||||
match t.get_attribute("class") {
|
match t.get_attribute("class") {
|
||||||
Some(class) => t
|
Some(class) => t
|
||||||
.set_attribute("class", &[&class, "animated-link-underline"].concat())
|
.set_attribute("class", &[&class, " animated-link-underline"].concat())
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
None => {
|
None => {
|
||||||
t.set_attribute("class", "animated-link-underline")
|
t.set_attribute("class", "animated-link-underline")
|
||||||
|
@ -769,12 +771,6 @@ where
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn footer<S>(input: S) -> String
|
|
||||||
// where
|
|
||||||
// S: AsRef<str>,
|
|
||||||
// {
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub(crate) fn sanitize<S: AsRef<str>>(input: S) -> String {
|
pub(crate) fn sanitize<S: AsRef<str>>(input: S) -> String {
|
||||||
rewrite_str(
|
rewrite_str(
|
||||||
input.as_ref(),
|
input.as_ref(),
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="stylesheet" href="/assets/css/style.css" />
|
<link rel="stylesheet" href="/assets/css/style.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue