Add meta tags to blog posts

This commit is contained in:
august kline 2025-01-06 19:16:25 -05:00
parent cb6e666a6e
commit f7b850d62a
2 changed files with 8 additions and 12 deletions

View File

@ -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()
},
)
@ -754,7 +756,7 @@ where
element_content_handlers: vec![element!("a", move |t| {
match t.get_attribute("class") {
Some(class) => t
.set_attribute("class", &[&class, "animated-link-underline"].concat())
.set_attribute("class", &[&class, " animated-link-underline"].concat())
.unwrap_or_default(),
None => {
t.set_attribute("class", "animated-link-underline")
@ -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(),

View File

@ -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>