refactor modules

This commit is contained in:
2024-08-07 13:18:13 +02:00
parent 6dc6a581e3
commit 5365cb5409
24 changed files with 139 additions and 130 deletions

View File

@ -2,26 +2,25 @@ use askama::Template;
use axum::http::StatusCode;
use crate::{
pages::post::{PostMetadata, BLOG_POST_PATH},
post_list::get_post_list,
post_parser::ParseResult,
blog_posts::blog_post_model::{BlogPostMetadata, BLOG_POST_PATH},
post_utils::{post_listing::get_post_list, post_parser::ParseResult},
};
#[derive(Template)]
#[template(path = "site_footer.html")]
pub struct SiteFooter {
pub latest_posts: Vec<ParseResult<PostMetadata>>,
pub latest_posts: Vec<ParseResult<BlogPostMetadata>>,
}
// TODO remove whole site footer anyway
pub async fn render_site_footer() -> Result<SiteFooter, StatusCode> {
let mut post_list = get_post_list::<PostMetadata>(BLOG_POST_PATH).await?;
let mut post_list = get_post_list::<BlogPostMetadata>(BLOG_POST_PATH).await?;
post_list.sort_by_key(|post| post.metadata.date);
post_list.reverse();
let latest_posts = post_list
.into_iter()
.take(6)
.collect::<Vec<ParseResult<PostMetadata>>>();
.collect::<Vec<ParseResult<BlogPostMetadata>>>();
Ok(SiteFooter { latest_posts })
}