NOT WORKING
This commit is contained in:
@@ -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>
|
||||
*/
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user