NOT WORKING

This commit is contained in:
2024-03-29 23:35:38 +02:00
parent b7cf19f229
commit 8a23681a12
3 changed files with 48 additions and 52 deletions

View File

@@ -6,12 +6,31 @@ use askama::Template;
use crate::{database::Database, web::templates::IndexTemplate};
use super::templates::IndexTemplatePost;
// NOTE: Not usefull to have database here but just so u know how
pub async fn index(_: Data<Mutex<Database>>) -> Result<impl Responder> {
let html = IndexTemplate {
placeholder: "hewwo world"
posts: vec![
IndexTemplatePost {
image: String::from("/static/assets/uwu.jpg"),
title: String::from("Cutie"),
description: String::from("Yes you are ;3"),
url: String::from("https://djc.github.io/askama/template_expansion.html")
}
],
title: String::from("Very cool mcoranges website :3"),
}.render().expect("Failed to render index.html");
Ok(Html(html))
}
}
/*
<div class="post">
<img src="/static/assets/uwu.jpg" alt="post img">
<span>
<h2>Title text</h3>
<p>Description text</p>
</span>
</div>
*/

View File

@@ -1,7 +1,16 @@
use askama::Template;
#[derive(Debug, Clone, Copy, Template)]
#[derive(Debug, Clone, Template)]
#[template(path = "index.html")]
pub struct IndexTemplate<'a> {
pub placeholder: &'a str,
}
pub struct IndexTemplate{
pub title: String,
pub posts: Vec<IndexTemplatePost>
}
#[derive(Debug, Clone)]
pub struct IndexTemplatePost {
pub image: String,
pub title: String,
pub description: String,
pub url: String
}