blog/backend/src/web/templates.rs

57 lines
1.2 KiB
Rust

use actix_web::http;
use askama_actix::Template;
use chrono::prelude::*;
use serde::{Deserialize, Serialize};
use crate::cache;
#[derive(Template)]
#[template(path = "status_code.html")]
pub struct StatusCode {
pub status_code: http::StatusCode,
pub message: Option<String>,
}
#[derive(Template)]
#[template(path = "web/index.html")]
pub struct Index;
#[derive(Template)]
#[template(path = "web/about.html")]
pub struct About;
#[derive(Serialize, Deserialize, Debug)]
pub struct PostIndexPost {
pub name: String,
pub slug: String,
pub description: String,
pub published_at: NaiveDate,
pub edited_at: Option<NaiveDate>,
pub tags: Vec<String>,
}
#[derive(Template)]
#[template(path = "web/posts/index.html")]
pub struct Posts {
pub posts: Vec<PostIndexPost>,
}
#[derive(Template)]
#[template(path = "web/posts/{slug}.html")]
pub struct PostBySlug {
// pub name: String,
// pub slug: String,
// pub published_at: NaiveDate,
// pub edited_at: Option<NaiveDate>,
// pub tags: Vec<String>,
// pub content: String,
pub post: cache::Post,
}
#[derive(Template)]
#[template(path = "web/tags/{name}.html")]
pub struct TagByName {
pub name: String,
pub posts: Vec<PostIndexPost>,
}