change the whole parsing of markdown functionality
This commit is contained in:
@ -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"
|
||||
|
@ -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
46
src/pages/portfolio.rs
Normal 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,
|
||||
})
|
||||
}
|
@ -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,
|
||||
};
|
||||
|
Reference in New Issue
Block a user