Add layout and feeds page, add hotwire
This commit is contained in:
20
src/handlers/feeds.rs
Normal file
20
src/handlers/feeds.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use axum::extract::State;
|
||||
use axum::response::Response;
|
||||
use maud::html;
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::models::feed::get_feeds;
|
||||
use crate::partials::layout::Layout;
|
||||
|
||||
pub async fn get(State(pool): State<PgPool>, layout: Layout) -> Result<Response> {
|
||||
let feeds = get_feeds(&pool).await?;
|
||||
Ok(layout.render(html! {
|
||||
ul {
|
||||
@for feed in feeds {
|
||||
@let title = feed.title.unwrap_or_else(|| "Untitled Feed".to_string());
|
||||
li { (title) }
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
use axum::extract::State;
|
||||
use maud::{html, Markup};
|
||||
use axum::response::Response;
|
||||
use maud::html;
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::models::entry::get_entries;
|
||||
use crate::partials::header::header;
|
||||
use crate::partials::layout::Layout;
|
||||
|
||||
pub async fn get(State(pool): State<PgPool>) -> Result<Markup> {
|
||||
pub async fn get(State(pool): State<PgPool>, layout: Layout) -> Result<Response> {
|
||||
let entries = get_entries(&pool).await?;
|
||||
Ok(html! {
|
||||
(header())
|
||||
Ok(layout.render(html! {
|
||||
ul {
|
||||
@for entry in entries {
|
||||
@let title = entry.title.unwrap_or_else(|| "Untitled".to_string());
|
||||
li { (title) }
|
||||
}
|
||||
}
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
pub mod api;
|
||||
pub mod home;
|
||||
pub mod feeds;
|
||||
|
||||
Reference in New Issue
Block a user