diff options
| author | Xe Iaso <me@christine.website> | 2022-06-08 14:58:29 -0400 |
|---|---|---|
| committer | Xe Iaso <me@christine.website> | 2022-06-08 15:02:52 -0400 |
| commit | dc3f6471e774eaafab92dfcd73dd089707646469 (patch) | |
| tree | 3b69a8d6f1f05b6c59086f14ae0cbef9ae248a24 /src/app | |
| parent | 396150f72bcd4545864d96f50afbf39cb6c15afb (diff) | |
| download | xesite-dc3f6471e774eaafab92dfcd73dd089707646469.tar.xz xesite-dc3f6471e774eaafab92dfcd73dd089707646469.zip | |
Add hero image support with <xeblog-hero>
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 <me@christine.website>
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/markdown.rs | 9 |
1 files changed, 7 insertions, 2 deletions
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<String> { 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#" <div class="conversation"> <div class="conversation-picture conversation-smol"> @@ -95,6 +95,11 @@ pub fn render(inp: &str) -> Result<String> { 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() |
