This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -34,20 +34,21 @@ fn load_posts() -> Result<HashMap<String, Post>, 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<HashMap<String, Post>, 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<String>
|
||||
render: Html<String>,
|
||||
slug: String
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -123,6 +123,11 @@ a {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.top-image {
|
||||
max-height: 40vh;
|
||||
max-width: 1000px;
|
||||
}
|
||||
|
||||
nav ul {
|
||||
list-style: none;
|
||||
display: flex;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
{% block body %}
|
||||
|
||||
<div class="post">
|
||||
<img src="{{ image }}" class="top-image">
|
||||
{{ content|safe }}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user