remove site_footer rust code
This commit is contained in:
parent
64efecfde2
commit
b136f46a6f
@ -1,2 +1 @@
|
||||
pub mod site_footer;
|
||||
pub mod site_header;
|
||||
|
@ -1,26 +0,0 @@
|
||||
use askama::Template;
|
||||
use axum::http::StatusCode;
|
||||
|
||||
use crate::{
|
||||
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<BlogPostMetadata>>,
|
||||
}
|
||||
|
||||
// TODO remove whole site footer anyway
|
||||
pub async fn render_site_footer() -> Result<SiteFooter, StatusCode> {
|
||||
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<BlogPostMetadata>>>();
|
||||
Ok(SiteFooter { latest_posts })
|
||||
}
|
@ -3,10 +3,7 @@ use axum::{extract::Path, http::StatusCode};
|
||||
|
||||
use crate::{
|
||||
blog_posts::blog_post_model::{BlogPostMetadata, BLOG_POST_PATH},
|
||||
components::{
|
||||
site_footer::{render_site_footer, SiteFooter},
|
||||
site_header::{HeaderProps, Link},
|
||||
},
|
||||
components::site_header::{HeaderProps, Link},
|
||||
filters,
|
||||
post_utils::{post_listing::get_post_list, post_parser::ParseResult},
|
||||
};
|
||||
@ -17,7 +14,6 @@ pub struct PostListTemplate {
|
||||
pub title: String,
|
||||
pub posts: Vec<ParseResult<BlogPostMetadata>>,
|
||||
pub tag: Option<String>,
|
||||
pub site_footer: SiteFooter,
|
||||
pub header_props: HeaderProps,
|
||||
}
|
||||
|
||||
@ -27,7 +23,6 @@ pub async fn render_blog_post_list(
|
||||
// I will forget what happens here in a week. But essentially it's pattern matching and shadowing
|
||||
let tag = tag.map(|Path(tag)| tag);
|
||||
|
||||
let site_footer = render_site_footer().await?;
|
||||
let mut post_list = get_post_list::<BlogPostMetadata>(BLOG_POST_PATH).await?;
|
||||
post_list.sort_by_key(|post| post.metadata.date);
|
||||
post_list.retain(|post| post.metadata.published);
|
||||
@ -60,7 +55,6 @@ pub async fn render_blog_post_list(
|
||||
title: "Posts".to_owned(),
|
||||
posts,
|
||||
tag,
|
||||
site_footer,
|
||||
header_props,
|
||||
})
|
||||
}
|
||||
|
@ -1,17 +1,13 @@
|
||||
use askama::Template;
|
||||
use axum::{extract::Path, http::StatusCode};
|
||||
use chrono::{DateTime, Utc};
|
||||
use tokio::try_join;
|
||||
|
||||
use crate::{
|
||||
blog_posts::blog_post_model::BlogPostMetadata, components::site_header::Link, filters,
|
||||
post_utils::post_parser::parse_post,
|
||||
};
|
||||
|
||||
use crate::components::{
|
||||
site_footer::{render_site_footer, SiteFooter},
|
||||
site_header::HeaderProps,
|
||||
};
|
||||
use crate::components::site_header::HeaderProps;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "blog_post.html")]
|
||||
@ -20,21 +16,19 @@ pub struct BlogPostTemplate {
|
||||
pub body: String,
|
||||
pub date: DateTime<Utc>,
|
||||
pub tags: Vec<String>,
|
||||
pub site_footer: SiteFooter,
|
||||
pub header_props: HeaderProps,
|
||||
}
|
||||
|
||||
pub async fn render_blog_post(Path(post_id): Path<String>) -> Result<BlogPostTemplate, StatusCode> {
|
||||
let path = format!("../_posts/blog/{}.md", post_id);
|
||||
let parse_post = parse_post::<BlogPostMetadata>(&path);
|
||||
let (site_footer, parsed) = try_join!(render_site_footer(), parse_post)?;
|
||||
let parsed = parse_post.await?;
|
||||
|
||||
Ok(BlogPostTemplate {
|
||||
title: parsed.metadata.title,
|
||||
date: parsed.metadata.date,
|
||||
tags: parsed.metadata.tags,
|
||||
body: parsed.body,
|
||||
site_footer,
|
||||
header_props: HeaderProps::with_back_link(Link {
|
||||
href: "/blog".to_string(),
|
||||
label: "All posts".to_string(),
|
||||
|
@ -1,10 +1,7 @@
|
||||
use askama::Template;
|
||||
use axum::http::StatusCode;
|
||||
|
||||
use crate::components::{
|
||||
site_footer::{render_site_footer, SiteFooter},
|
||||
site_header::HeaderProps,
|
||||
};
|
||||
use crate::components::site_header::HeaderProps;
|
||||
|
||||
pub struct ContactLink {
|
||||
pub href: String,
|
||||
@ -17,13 +14,11 @@ pub struct ContactLink {
|
||||
#[template(path = "contact.html")]
|
||||
pub struct ContactPageTemplate {
|
||||
pub title: String,
|
||||
pub site_footer: SiteFooter,
|
||||
pub header_props: HeaderProps,
|
||||
pub links: Vec<ContactLink>,
|
||||
}
|
||||
|
||||
pub async fn render_contact() -> Result<ContactPageTemplate, StatusCode> {
|
||||
let site_footer = render_site_footer().await?;
|
||||
let links = vec![
|
||||
ContactLink {
|
||||
href: "mailto: michalvankosk@gmail.com".to_string(),
|
||||
@ -77,7 +72,6 @@ pub async fn render_contact() -> Result<ContactPageTemplate, StatusCode> {
|
||||
|
||||
Ok(ContactPageTemplate {
|
||||
title: "Contact".to_owned(),
|
||||
site_footer,
|
||||
header_props: HeaderProps::default(),
|
||||
links,
|
||||
})
|
||||
|
@ -7,10 +7,7 @@ use crate::{
|
||||
blog_post_model::BlogPostMetadata, featured_blog_posts::get_featured_blog_posts,
|
||||
tag_list::get_popular_blog_tags,
|
||||
},
|
||||
components::{
|
||||
site_footer::{render_site_footer, SiteFooter},
|
||||
site_header::HeaderProps,
|
||||
},
|
||||
components::site_header::HeaderProps,
|
||||
filters,
|
||||
post_utils::post_parser::ParseResult,
|
||||
projects::{featured_projects::get_featured_projects, project_model::ProjectMetadata},
|
||||
@ -19,7 +16,6 @@ use crate::{
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
pub struct IndexTemplate {
|
||||
site_footer: SiteFooter,
|
||||
header_props: HeaderProps,
|
||||
blog_tags: Vec<String>,
|
||||
featured_blog_posts: Vec<ParseResult<BlogPostMetadata>>,
|
||||
@ -27,15 +23,13 @@ pub struct IndexTemplate {
|
||||
}
|
||||
|
||||
pub async fn render_index() -> Result<IndexTemplate, StatusCode> {
|
||||
let (site_footer, blog_tags, featured_blog_posts, featured_projects) = try_join!(
|
||||
render_site_footer(),
|
||||
let (blog_tags, featured_blog_posts, featured_projects) = try_join!(
|
||||
get_popular_blog_tags(),
|
||||
get_featured_blog_posts(),
|
||||
get_featured_projects()
|
||||
)?;
|
||||
|
||||
Ok(IndexTemplate {
|
||||
site_footer,
|
||||
header_props: HeaderProps::default(),
|
||||
blog_tags,
|
||||
featured_blog_posts,
|
||||
|
Loading…
Reference in New Issue
Block a user