Files
crawlnicle/src/handlers/home.rs
Tyler Hallada a3450e202a Working apalis cron and worker with 0.6.0-rc.5
Also renamed `pool` variables throughout codebase to `db` for clarity.
2024-08-21 01:21:45 -04:00

25 lines
672 B
Rust

use axum::extract::State;
use axum::response::Response;
use axum_extra::TypedHeader;
use maud::html;
use sqlx::PgPool;
use crate::error::Result;
use crate::htmx::HXTarget;
use crate::models::entry::Entry;
use crate::partials::{entry_list::entry_list, layout::Layout};
pub async fn get(
State(db): State<PgPool>,
hx_target: Option<TypedHeader<HXTarget>>,
layout: Layout,
) -> Result<Response> {
let options = Default::default();
let entries = Entry::get_all(&db, &options).await?;
Ok(layout.targeted(hx_target).render(html! {
ul class="list-none flex flex-col gap-4" {
(entry_list(entries, &options, true))
}
}))
}