Add maud for frontend and move api to sub module

This commit is contained in:
2023-06-01 00:03:00 -04:00
parent 9059894021
commit 1698ef9c60
10 changed files with 58 additions and 10 deletions

4
src/handlers/api/mod.rs Normal file
View File

@@ -0,0 +1,4 @@
pub mod feed;
pub mod feeds;
pub mod entry;
pub mod entries;

19
src/handlers/home.rs Normal file
View 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) }
}
}
})
}

View File

@@ -1,4 +1,2 @@
pub mod feed;
pub mod feeds;
pub mod entry;
pub mod entries;
pub mod api;
pub mod home;