Add header partial

This commit is contained in:
Tyler Hallada 2023-06-01 00:59:39 -04:00
parent 1698ef9c60
commit e501c15c66
4 changed files with 18 additions and 1 deletions

View File

@ -4,11 +4,12 @@ use sqlx::PgPool;
use crate::error::Result; use crate::error::Result;
use crate::models::entry::get_entries; use crate::models::entry::get_entries;
use crate::partials::header::header;
pub async fn get(State(pool): State<PgPool>) -> Result<Markup> { pub async fn get(State(pool): State<PgPool>) -> Result<Markup> {
let entries = get_entries(&pool).await?; let entries = get_entries(&pool).await?;
Ok(html! { Ok(html! {
h1 { "crawlnicle" } (header())
ul { ul {
@for entry in entries { @for entry in entries {
@let title = entry.title.unwrap_or_else(|| "Untitled".to_string()); @let title = entry.title.unwrap_or_else(|| "Untitled".to_string());

View File

@ -2,3 +2,4 @@ pub mod error;
pub mod handlers; pub mod handlers;
pub mod jobs; pub mod jobs;
pub mod models; pub mod models;
pub mod partials;

14
src/partials/header.rs Normal file
View File

@ -0,0 +1,14 @@
use maud::{html, Markup};
pub fn header() -> Markup {
html! {
header {
nav {
h1 { a href="/" { "crawlnicle" } }
ul {
li { a href="/feeds" { "feeds" } }
}
}
}
}
}

1
src/partials/mod.rs Normal file
View File

@ -0,0 +1 @@
pub mod header;