feat: add page system behing navbar items and skeletons for loading
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
10
crates/app/src/pages/cps.rs
Normal file
10
crates/app/src/pages/cps.rs
Normal 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()
|
||||
}
|
10
crates/app/src/pages/home.rs
Normal file
10
crates/app/src/pages/home.rs
Normal 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()
|
||||
}
|
10
crates/app/src/pages/mod.rs
Normal file
10
crates/app/src/pages/mod.rs
Normal 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))
|
||||
}
|
@ -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,
|
||||
},
|
||||
],
|
||||
|
Reference in New Issue
Block a user