working markdown to html

This commit is contained in:
2026-01-24 20:18:55 -05:00
parent 4af1325ad6
commit f9d58cbd7c
15 changed files with 503 additions and 421 deletions

View File

@@ -1,22 +1,38 @@
use axum::{
routing::get,
Router,
response::Html,
Router, response::Html, routing::get
};
use tower_http::services::ServeDir;
use askama::Template;
use markdown::to_html;
use std::fs;
// Template for home
#[derive(Template)]
#[template(path = "home.html", ext = "html")]
struct HomeTemplate {
content: String
}
#[tokio::main]
async fn main() {
let site = Router::new()
.route("/", get(home))
let home_html = Html(
HomeTemplate {
content: to_html(&fs::read_to_string(
"static/strings/home.md"
).expect("Couldnt read file"))
}.render().unwrap()
);
let site: Router = Router::new()
.route("/", get(home_html))
.nest_service("/static", ServeDir::new("static"));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
println!("Running on http://127.0.0.1:3000");
axum::serve(listener, site).await.unwrap();
}
async fn home() -> Html<&'static str> {
const HTML: &'static str = include_str!("../static/home.html");
Html(HTML)
}