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)
|
let summary = re_summary.captures(&typst)
|
||||||
.expect("Post summary not found")
|
.expect("Post summary not found")
|
||||||
.get(1).unwrap().as_str().trim().to_string();
|
.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)
|
re_img.captures(&typst)
|
||||||
.expect("Post preview image not found")
|
.expect("Post preview image not found")
|
||||||
.get(1).unwrap().as_str().trim().to_string()
|
.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(
|
posts.insert(
|
||||||
slug.clone(),
|
slug.clone(),
|
||||||
Post {
|
Post {
|
||||||
slug: slug,
|
slug: slug,
|
||||||
title: title,
|
title: title,
|
||||||
preview_image: img_path,
|
preview_image: img_path.clone(),
|
||||||
summary: summary,
|
summary: summary,
|
||||||
render: Html(PostTemplate {
|
render: Html(PostTemplate {
|
||||||
content: typst_to_html(typst),
|
content: typst_to_html(typst),
|
||||||
|
image: img_path
|
||||||
}.render().expect("Failed rendering post")),
|
}.render().expect("Failed rendering post")),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -58,6 +59,7 @@ fn load_posts() -> Result<HashMap<String, Post>, Error> {
|
|||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "post.html")]
|
#[template(path = "post.html")]
|
||||||
struct PostTemplate {
|
struct PostTemplate {
|
||||||
|
image: String,
|
||||||
content: String,
|
content: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +69,8 @@ struct Post {
|
|||||||
title: String,
|
title: String,
|
||||||
preview_image: String,
|
preview_image: String,
|
||||||
summary: String,
|
summary: String,
|
||||||
slug: String,
|
render: Html<String>,
|
||||||
render: Html<String>
|
slug: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,11 @@ a {
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.top-image {
|
||||||
|
max-height: 40vh;
|
||||||
|
max-width: 1000px;
|
||||||
|
}
|
||||||
|
|
||||||
nav ul {
|
nav ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
<div class="post">
|
<div class="post">
|
||||||
|
<img src="{{ image }}" class="top-image">
|
||||||
{{ content|safe }}
|
{{ content|safe }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user