404: make page responsive and make partial system for it

This commit is contained in:
Agahnim 2026-03-20 16:15:07 +01:00
parent fbfa39399f
commit 55ac79f702
4 changed files with 40 additions and 9 deletions

View file

@ -1,10 +1,34 @@
use std::sync::Arc;
use askama::Template;
use axum::response::{Html, IntoResponse};
use axum::{
extract::State,
http::HeaderMap,
response::{Html, IntoResponse},
};
use crate::domain::AppState;
#[derive(Template)]
#[template(path = "notfound.html")]
struct NotfoundTemplate;
pub async fn notfound() -> impl IntoResponse {
Html(NotfoundTemplate.render().unwrap())
struct NotfoundTemplate {
tracks: Vec<crate::domain::Track>,
}
#[derive(Template)]
#[template(path = "partials/notfound.html")]
struct NotfoundPartialTemplate;
pub async fn notfound(headers: HeaderMap, state: State<Arc<AppState>>) -> impl IntoResponse {
if headers.contains_key("hx-request") {
Html(NotfoundPartialTemplate.render().unwrap())
} else {
Html(
NotfoundTemplate {
tracks: state.mp_tracks.clone(),
}
.render()
.unwrap(),
)
}
}