Add rudimentary entry page, fix main frame link navigation

This commit is contained in:
2023-06-02 00:31:25 -04:00
parent 0b7acadd60
commit ea236dff4e
5 changed files with 23 additions and 2 deletions

18
src/handlers/entry.rs Normal file
View File

@@ -0,0 +1,18 @@
use axum::extract::{State, Path};
use axum::response::Response;
use maud::html;
use sqlx::PgPool;
use crate::error::Result;
use crate::models::entry::get_entry;
use crate::partials::layout::Layout;
pub async fn get(Path(id): Path<i32>, State(pool): State<PgPool>, layout: Layout) -> Result<Response> {
let entry = get_entry(&pool, id).await?;
Ok(layout.render(html! {
@let title = entry.title.unwrap_or_else(|| "Untitled".to_string());
h1 { a href=(entry.url) { (title) } }
@let description = entry.description.unwrap_or_else(|| "No description".to_string());
p { (description) }
}))
}