Fix env vars
This commit is contained in:
parent
35331ef076
commit
ab494f8381
|
@ -1,3 +1,4 @@
|
|||
use std::borrow::Borrow;
|
||||
use std::{env, vec};
|
||||
|
||||
use blogdb::posts::Post;
|
||||
|
@ -447,14 +448,30 @@ where
|
|||
element_content_handlers: vec![element!("meta", |meta| {
|
||||
if let Some(attr) = meta.get_attribute("property") {
|
||||
let content = match attr.as_str() {
|
||||
"og:url" => &["https://", env!("DOMAIN"), slug.as_ref()].concat(),
|
||||
"og:url" => {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
&["http://localhost", slug.as_ref()].concat()
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
&["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() {
|
||||
&["https://", env!("DOMAIN"), image].concat()
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
&["http://localhost", image].concat()
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
&["https://", env!("DOMAIN"), image].concat()
|
||||
}
|
||||
} else {
|
||||
meta.remove();
|
||||
""
|
||||
|
@ -482,7 +499,7 @@ where
|
|||
let html = make_page(template, PageSettings::title("Blog"));
|
||||
|
||||
let post = db.get_post(id).await.unwrap_or_default();
|
||||
let head = head::<_, _, [String; 0]>(post.title, []);
|
||||
let head_content = head::<_, _, [String; 0]>(post.title, []);
|
||||
let post_content: Blocks = serde_json::from_str(&post.content).unwrap_or_default();
|
||||
let post_html: String = post_content.to_html();
|
||||
let image = if let Some(url) = post_content.image() {
|
||||
|
@ -504,8 +521,17 @@ where
|
|||
time.after(&post_html, ContentType::Html);
|
||||
time.replace(
|
||||
&[
|
||||
r#"<a class="animated-link" style="align-self: flex-start; margin-block-end: 0" href="https://"#,
|
||||
env!("DOMAIN"),
|
||||
r#"<a class="animated-link" style="align-self: flex-start; margin-block-end: 0" href=""#,
|
||||
{
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
"http://localhost"
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
&["https://", env!("DOMAIN")].concat()
|
||||
}
|
||||
},
|
||||
"/blog/",
|
||||
&post.id,
|
||||
r#""><time>"#,
|
||||
|
@ -517,6 +543,7 @@ where
|
|||
);
|
||||
Ok(())
|
||||
}), element!("head", |head| {
|
||||
head.replace(&head_content, ContentType::Html);
|
||||
head.append(&meta, ContentType::Html);
|
||||
Ok(())
|
||||
})],
|
||||
|
|
Loading…
Reference in New Issue