From fb23b004ce99e6c74e3c786e93800060991cdb69 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 31 Jan 2026 21:40:17 -0500 Subject: [PATCH] more images! --- src/main.rs | 12 +++++++----- static/style.css | 5 +++++ templates/post.html | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index a93669e..07d12f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,20 +34,21 @@ fn load_posts() -> Result, Error> { let summary = re_summary.captures(&typst) .expect("Post summary not found") .get(1).unwrap().as_str().trim().to_string(); - let img_path = dir?.path().join( + let img_path = "/".to_string() + dir?.path().join( re_img.captures(&typst) .expect("Post preview image not found") .get(1).unwrap().as_str().trim().to_string() - ).to_str().expect("Failed converting path to string").to_string(); + ).to_str().expect("Failed converting path to string"); posts.insert( slug.clone(), Post { slug: slug, title: title, - preview_image: img_path, + preview_image: img_path.clone(), summary: summary, render: Html(PostTemplate { content: typst_to_html(typst), + image: img_path }.render().expect("Failed rendering post")), } ); @@ -58,6 +59,7 @@ fn load_posts() -> Result, Error> { #[derive(Template)] #[template(path = "post.html")] struct PostTemplate { + image: String, content: String, } @@ -67,8 +69,8 @@ struct Post { title: String, preview_image: String, summary: String, - slug: String, - render: Html + render: Html, + slug: String } diff --git a/static/style.css b/static/style.css index 81fab97..ceefaed 100644 --- a/static/style.css +++ b/static/style.css @@ -123,6 +123,11 @@ a { text-align: left; } +.top-image { + max-height: 40vh; + max-width: 1000px; +} + nav ul { list-style: none; display: flex; diff --git a/templates/post.html b/templates/post.html index f6af174..80e8bfd 100644 --- a/templates/post.html +++ b/templates/post.html @@ -3,6 +3,7 @@ {% block body %}
+ {{ content|safe }}