404: make page responsive and make partial system for it
This commit is contained in:
parent
401c2b738d
commit
6e0e250a7c
4 changed files with 40 additions and 9 deletions
|
|
@ -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(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue