feat: implement htmx with partials on index and cps pages
This commit is contained in:
@ -2,6 +2,7 @@ use std::path::Path;
|
||||
|
||||
use askama_axum::Template;
|
||||
use axum::http::{StatusCode, Uri};
|
||||
use axum_htmx::{AutoVaryLayer, HxRequest};
|
||||
use tower_http::services::ServeDir;
|
||||
|
||||
mod menu;
|
||||
@ -13,10 +14,12 @@ async fn fallback(uri: Uri) -> (StatusCode, String) {
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "index.html")]
|
||||
pub struct GetIndexTemplate;
|
||||
pub struct GetIndexTemplate {
|
||||
hx_request: bool,
|
||||
}
|
||||
|
||||
async fn root() -> GetIndexTemplate {
|
||||
GetIndexTemplate {}
|
||||
async fn root(HxRequest(hx_request): HxRequest) -> GetIndexTemplate {
|
||||
GetIndexTemplate { hx_request }
|
||||
}
|
||||
|
||||
pub fn get_router(assets_path: &Path) -> axum::Router {
|
||||
@ -25,4 +28,5 @@ pub fn get_router(assets_path: &Path) -> axum::Router {
|
||||
.route("/", axum::routing::get(root))
|
||||
.merge(pages::get_routes())
|
||||
.fallback(fallback)
|
||||
.layer(AutoVaryLayer)
|
||||
}
|
||||
|
Reference in New Issue
Block a user