feat: add page system behing navbar items and skeletons for loading

This commit is contained in:
2024-08-06 00:18:09 +02:00
parent 898ee32f9a
commit e084372b44
15 changed files with 392 additions and 16 deletions

View File

@ -1,3 +1,4 @@
mod pages;
mod templates;
use std::path::Path;
@ -23,6 +24,7 @@ pub fn get_router(assets_path: &Path) -> axum::Router {
axum::Router::new()
.nest_service("/assets", ServeDir::new(assets_path))
.route("/", axum::routing::get(root))
.nest("/pages", pages::get_routes())
.merge(templates::get_routes())
.fallback(fallback)
}

View File

@ -0,0 +1,10 @@
use askama::Template;
use askama_axum::IntoResponse;
#[derive(Template)]
#[template(path = "pages/cps.html")]
struct CpsResponse;
pub async fn cps() -> impl IntoResponse {
CpsResponse.into_response()
}

View File

@ -0,0 +1,10 @@
use askama::Template;
use askama_axum::IntoResponse;
#[derive(Template)]
#[template(path = "pages/home.html")]
struct HomeResponse;
pub async fn home() -> impl IntoResponse {
HomeResponse.into_response()
}

View File

@ -0,0 +1,10 @@
use axum::{routing, Router};
mod cps;
mod home;
pub fn get_routes() -> Router {
Router::new()
.route("/home", routing::get(home::home))
.route("/cps", routing::get(cps::cps))
}

View File

@ -5,7 +5,7 @@ use serde::Deserialize;
struct MenuItem {
label: String,
id: String,
href: String,
current: bool,
}
@ -42,17 +42,12 @@ async fn menu(Query(params): Query<MenuParameters>) -> impl IntoResponse {
items: vec![
MenuItem {
label: "Accueil".to_string(),
id: "home".to_string(),
href: "/pages/home".to_string(),
current: true,
},
MenuItem {
label: "À propos".to_string(),
id: "about".to_string(),
current: false,
},
MenuItem {
label: "Contact".to_string(),
id: "contact".to_string(),
label: "CPS".to_string(),
href: "/pages/cps".to_string(),
current: false,
},
],