change the whole parsing of markdown functionality

This commit is contained in:
2024-10-07 15:35:22 +02:00
parent fb6ca6c245
commit 11cc9f6d0a
21 changed files with 311 additions and 264 deletions

View File

@ -29,7 +29,7 @@ pub async fn render_blog_post(
OriginalUri(original_uri): OriginalUri,
) -> Result<BlogPostTemplate, StatusCode> {
let path = format!("{}/{}.md", BLOG_POST_PATH, post_id);
let parse_post = parse_post::<BlogPostMetadata>(&path, true);
let parse_post = parse_post::<BlogPostMetadata>(&path);
let parsed = parse_post.await?;
let segment = if original_uri.to_string().starts_with("/blog") {
"blog"

View File

@ -5,6 +5,7 @@ pub mod broadcast_list;
pub mod contact;
pub mod index;
pub mod not_found;
pub mod portfolio;
pub mod post_list;
pub mod project_list;
pub mod showcase;

46
src/pages/portfolio.rs Normal file
View File

@ -0,0 +1,46 @@
use askama::Template;
use axum::http::StatusCode;
use serde::Deserialize;
use crate::{
components::site_header::HeaderProps,
filters,
post_utils::{
post_listing::get_post_list,
post_parser::{parse_post, ParseResult},
},
projects::project_model::ProjectMetadata,
};
#[derive(Deserialize, Debug)]
pub struct PortfolioPageModel {
pub title: String,
// TODO work_history
// TODO education
}
#[derive(Template)]
#[template(path = "portfolio.html")]
pub struct PortfolioTemplate {
pub title: String,
pub body: String,
pub project_list: Vec<ParseResult<ProjectMetadata>>,
pub header_props: HeaderProps,
}
pub async fn render_portfolio() -> Result<PortfolioTemplate, StatusCode> {
let portfolio = parse_post::<PortfolioPageModel>("_pages/portfolio.md").await?;
let mut project_list = get_post_list::<ProjectMetadata>("_projects").await?;
project_list.sort_by_key(|post| post.slug.to_string());
project_list.retain(|project| project.metadata.displayed);
project_list.reverse();
Ok(PortfolioTemplate {
title: "Portfolio".to_owned(),
body: portfolio.body,
header_props: HeaderProps::default(),
project_list,
})
}

View File

@ -3,6 +3,7 @@ use axum::http::StatusCode;
use crate::{
components::site_header::HeaderProps,
filters,
post_utils::{post_listing::get_post_list, post_parser::ParseResult},
projects::project_model::ProjectMetadata,
};