use crate::html; use askama::Template; use axum::response::IntoResponse; use axum::{routing::get, Router}; use tower_http::services::ServeDir; pub fn get_router() -> Router { let assets_path = std::env::current_dir().unwrap(); Router::new() .nest("/api", html::api::get_router()) .nest("/blog", html::blog::get_router()) .nest("/projects", html::projects::get_router()) .route("/", get(home)) .route("/now", get(now)) .route("/about", get(about)) .route("/contact", get(contact)) .nest_service( "/assets", ServeDir::new(format!("{}/assets", assets_path.to_str().unwrap())), ) } async fn home() -> impl IntoResponse { let template = HomeTemplate {}; html::HtmlTemplate(template) } #[derive(Template)] #[template(path = "home.html")] struct HomeTemplate; pub async fn blog() -> impl IntoResponse { let template = BlogTemplate {}; html::HtmlTemplate(template) } #[derive(Template)] #[template(path = "blog.html")] struct BlogTemplate; pub async fn projects() -> impl IntoResponse { let template = ProjectsTemplate {}; html::HtmlTemplate(template) } #[derive(Template)] #[template(path = "projects.html")] struct ProjectsTemplate; async fn now() -> impl IntoResponse { let template = NowTemplate {}; html::HtmlTemplate(template) } #[derive(Template)] #[template(path = "now.html")] struct NowTemplate; async fn about() -> impl IntoResponse { let template = AboutTemplate {}; html::HtmlTemplate(template) } #[derive(Template)] #[template(path = "about.html")] struct AboutTemplate; async fn contact() -> impl IntoResponse { let template = ContactTemplate {}; html::HtmlTemplate(template) } #[derive(Template)] #[template(path = "contact.html")] struct ContactTemplate;