summaryrefslogblamecommitdiff
path: root/src/views/posts.rs
blob: 82b59964ec7d7f26d8eef3693e92df2350819dfd (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12











                                                                   



                                                            

     
use crate::helpers::*;
use crate::posts::abstractions::post::Post;
use askama::Template;

#[derive(Template)]
#[template(path = "posts.html")]
pub struct PostsView<P: Post> {
    posts: Vec<P>,
}

impl<P: Post> PostsView<P> {
    pub fn with_posts(posts: impl IntoIterator<Item = P>) -> Self {
        let mut posts: Vec<P> = posts.into_iter().collect();
        posts.sort();
        posts.reverse();
        Self { posts }
    }
}