Static site generator + my presonnal website written in rust for some reason.
1use axum::{extract::Path,response::Html}; 2use crate::structs::*; 3use crate::rand_quote::get_quote; 4use crate::blog_entries::{get_all_markdowns, get_blog_entry_markdown}; 5 6pub async fn index() -> Html<String> { 7 let all_entries = get_all_markdowns(); 8 let quote = get_quote(); 9 let new_page = IndexTemplate { random_quote: quote, index_post_entries:&all_entries}; 10 Html(new_page.to_string()) 11} 12 13pub async fn about() -> Html<String> { 14 15 let about_content = comrak::markdown_to_html("about", &comrak::Options::default()); 16 let page_content = AboutTemplate{about_content: &about_content}; 17 Html(page_content.to_string()) 18} 19 20 21pub async fn blog(Path(blog_path):Path<String>) -> Html<String> { 22 23 match get_blog_entry_markdown(&blog_path){ 24 Ok(markdown) => Html( 25 BlogTemplate{ 26 blog_content: &comrak::markdown_to_html(markdown.content(), &comrak::Options::default()), 27 front_matter:&serde_yaml::from_str(markdown.front_matter()).unwrap()}.to_string() 28 ), 29 Err(..) => not_found().await, 30 } 31 32} 33 34pub async fn not_found() -> Html<String> { 35 Html(NotFoundTemplate{}.to_string()) 36}