From 839c44e535d03f8ae747139acd27109e897c76e4 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 17 Sep 2022 02:27:29 +0000 Subject: push 2fa considered harmful Signed-off-by: Xe Iaso --- src/app/markdown.rs | 5 +++++ src/tmpl/mod.rs | 10 ++++++++++ 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/app/markdown.rs b/src/app/markdown.rs index 65d084d..9c3266e 100644 --- a/src/app/markdown.rs +++ b/src/app/markdown.rs @@ -98,6 +98,11 @@ pub fn render(cfg: Arc, inp: &str) -> Result { el.remove_and_keep_content(); Ok(()) }), + element!("xeblog-picture", |el| { + let path = el.get_attribute("path").expect("wanted xeblog-picture to contain path"); + el.replace(&crate::tmpl::xeblog_picture(path).0, ContentType::Html); + 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"), el.get_attribute("ai")).0, ContentType::Html); diff --git a/src/tmpl/mod.rs b/src/tmpl/mod.rs index c0b1089..ec7ccd5 100644 --- a/src/tmpl/mod.rs +++ b/src/tmpl/mod.rs @@ -48,6 +48,16 @@ pub fn xeblog_slide(name: String, essential: bool) -> Markup { } } +pub fn xeblog_picture(path: String) -> Markup { + html! { + picture style="margin:0" { + source type="image/avif" srcset={"https://cdn.xeiaso.net/file/christine-static/" (path) ".avif"}; + source type="image/webp" srcset={"https://cdn.xeiaso.net/file/christine-static/" (path) ".webp"}; + img style="padding:0" loading="lazy" alt={"hero image " (path)} src={"https://cdn.xeiaso.net/file/christine-static/" (path) "-smol.png"}; + } + } +} + pub fn xeblog_hero(file: String, prompt: Option, ai: Option) -> Markup { let ai = ai.unwrap_or("MidJourney".to_string()); html! { -- cgit v1.2.3