feat: Implement public blog post listing and individual post viewing with new public handlers and templates, adding chrono for date formatting.

This commit is contained in:
2026-03-03 17:11:26 +00:00
parent ef068f7dfa
commit 57f2610164
10 changed files with 303 additions and 24 deletions

View File

@@ -1,10 +1,4 @@
use askama::Template;
use axum::{
extract::State,
response::IntoResponse,
routing::get,
Router,
};
use axum::Router;
use sqlx::{sqlite::{SqliteConnectOptions, SqlitePoolOptions}, SqlitePool};
use std::str::FromStr;
use std::sync::Arc;
@@ -22,18 +16,7 @@ pub struct AppState {
pub db: SqlitePool,
}
#[derive(Template)]
#[template(path = "index.html")]
struct IndexTemplate {
title: String,
}
async fn index(State(_state): State<Arc<AppState>>) -> impl IntoResponse {
let template = IndexTemplate {
title: "Coming Soon".to_string(),
};
crate::utils::HtmlTemplate(template)
}
#[tokio::main]
async fn main() {
@@ -115,7 +98,7 @@ async fn main() {
let app_state = Arc::new(AppState { db: db_pool });
let app = Router::new()
.route("/", get(index))
.merge(handlers::public::router())
.nest("/__dungeon", handlers::router(&app_state)) // I'll create a single `handlers::router`
.with_state(app_state.clone())
.layer(tower_http::trace::TraceLayer::new_for_http());