diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/app/markdown.rs | 5 | ||||
| -rw-r--r-- | src/tmpl/mod.rs | 10 |
2 files changed, 15 insertions, 0 deletions
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<Config>, inp: &str) -> Result<String> { 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<String>, ai: Option<String>) -> Markup { let ai = ai.unwrap_or("MidJourney".to_string()); html! { |
