From ab494f83819d14d22b194675581445f2d2f0795a Mon Sep 17 00:00:00 2001 From: august kline Date: Mon, 6 Jan 2025 20:17:49 -0500 Subject: [PATCH] Fix env vars --- server/src/html.rs | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/server/src/html.rs b/server/src/html.rs index 5968648..55a06bf 100644 --- a/server/src/html.rs +++ b/server/src/html.rs @@ -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#"