Add maud for frontend and move api to sub module
This commit is contained in:
19
src/handlers/home.rs
Normal file
19
src/handlers/home.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use axum::extract::State;
|
||||
use maud::{html, Markup};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::models::entry::get_entries;
|
||||
|
||||
pub async fn get(State(pool): State<PgPool>) -> Result<Markup> {
|
||||
let entries = get_entries(&pool).await?;
|
||||
Ok(html! {
|
||||
h1 { "crawlnicle" }
|
||||
ul {
|
||||
@for entry in entries {
|
||||
@let title = entry.title.unwrap_or_else(|| "Untitled".to_string());
|
||||
li { (title) }
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user