From dc3f6471e774eaafab92dfcd73dd089707646469 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Wed, 8 Jun 2022 14:58:29 -0400 Subject: Add hero image support with Also lightens the JavaScript load and shifts ad impressions to only when people from Reddit and Hacker News visit. I may have this include Twitter in the future. Signed-off-by: Xe --- src/app/markdown.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/app') diff --git a/src/app/markdown.rs b/src/app/markdown.rs index e69b6e7..f6ae342 100644 --- a/src/app/markdown.rs +++ b/src/app/markdown.rs @@ -7,7 +7,7 @@ use comrak::{ ComrakPlugins, }; use lazy_static::lazy_static; -use lol_html::{rewrite_str, element, RewriteStrSettings, html_content::ContentType}; +use lol_html::{element, html_content::ContentType, rewrite_str, RewriteStrSettings}; use std::cell::RefCell; use url::Url; @@ -80,7 +80,7 @@ pub fn render(inp: &str) -> Result { let name = el.get_attribute("name").expect("wanted xeblog-conv to contain name"); let name_lower = name.clone().to_lowercase(); let mood = el.get_attribute("mood").expect("wanted xeblog-conv to contain mood"); - + el.before(&format!(r#"
@@ -95,6 +95,11 @@ pub fn render(inp: &str) -> Result { el.remove_and_keep_content(); Ok(()) + }), + element!("xeblog-hero", |el| { + let file = el.get_attribute("file").expect("wanted xeblog-hero to contain file"); + el.replace(&crate::tmpl::xeblog_hero(file, el.get_attribute("prompt")).0, ContentType::Html); + Ok(()) }) ], ..RewriteStrSettings::default() -- cgit v1.2.3