From 8c615338e5706326ccd5b0c49e25673511e1f872 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 19 Apr 2023 20:27:40 +0200 Subject: [PATCH] Add style of index --- src/routes/blog.rs | 9 ++++++++- templates/blog/index.html | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/routes/blog.rs b/src/routes/blog.rs index 1908fe0..1d99d47 100644 --- a/src/routes/blog.rs +++ b/src/routes/blog.rs @@ -14,7 +14,14 @@ pub async fn index(config: web::Data) -> impl Responder { #[derive(Content)] struct BlogIndexTemplate { - posts: Option>, + posts: Option>, +} + +#[derive(Content)] +struct Post { + title: String, + url: String, + file: File, } #[once(time = 60)] diff --git a/templates/blog/index.html b/templates/blog/index.html index 60d353a..7fec9ce 100644 --- a/templates/blog/index.html +++ b/templates/blog/index.html @@ -2,7 +2,17 @@ {{>head.html}} -

Index

- {{>footer.html}} + {{#data}} +

Blog

+
+ {{^posts}} +

Aucun posts

+ {{/posts}} {{#posts}} +

+ {{title}} +

+ {{/posts}} +
+ {{/data}} {{>footer.html}}