Tailwind for post_list
This commit is contained in:
@ -4,26 +4,20 @@ pub struct Link {
|
||||
}
|
||||
|
||||
pub struct HeaderProps {
|
||||
pub links: Vec<Link>,
|
||||
pub back_link: Option<Link>,
|
||||
}
|
||||
|
||||
impl Default for HeaderProps {
|
||||
fn default() -> Self {
|
||||
Self { back_link: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl HeaderProps {
|
||||
pub fn with_back_link(link: Link) -> Self {
|
||||
Self {
|
||||
links: vec![
|
||||
Link {
|
||||
href: "/".to_string(),
|
||||
label: "Introduction".to_string(),
|
||||
},
|
||||
Link {
|
||||
href: "/blog".to_string(),
|
||||
label: "Blog".to_string(),
|
||||
},
|
||||
Link {
|
||||
href: "/portfolio".to_string(),
|
||||
label: "Portfolio".to_string(),
|
||||
},
|
||||
],
|
||||
back_link: Some(link),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use axum;
|
||||
use tower_http::services::ServeDir;
|
||||
use tower_livereload::LiveReloadLayer;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
mod components;
|
||||
@ -25,6 +26,10 @@ async fn main() {
|
||||
|
||||
// build our application with a single route
|
||||
let app = router::get_router().nest_service("/styles", ServeDir::new("styles"));
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
let app = app.layer(LiveReloadLayer::new());
|
||||
|
||||
// run our app with hyper, listening globally on port 3080
|
||||
let port = std::option_env!("PORT").unwrap_or("3080");
|
||||
let addr = format!("0.0.0.0:{}", port);
|
||||
|
@ -4,7 +4,7 @@ use axum::{extract::Path, http::StatusCode};
|
||||
use crate::{
|
||||
components::{
|
||||
site_footer::{render_site_footer, SiteFooter},
|
||||
site_header::HeaderProps,
|
||||
site_header::{HeaderProps, Link},
|
||||
},
|
||||
post_list::get_post_list,
|
||||
post_parser::ParseResult,
|
||||
@ -50,12 +50,21 @@ pub async fn render_post_list(tag: Option<Path<String>>) -> Result<PostListTempl
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
|
||||
// TODO if we have a tag we want to go back to all posts, otherwise we don't
|
||||
let header_props = match tag {
|
||||
Some(_) => HeaderProps::with_back_link(Link {
|
||||
href: "/blog".to_string(),
|
||||
label: "All posts".to_string(),
|
||||
}),
|
||||
None => HeaderProps::default(),
|
||||
};
|
||||
|
||||
Ok(PostListTemplate {
|
||||
title: "Posts".to_owned(),
|
||||
posts,
|
||||
tag,
|
||||
site_footer,
|
||||
header_props: HeaderProps::default(),
|
||||
header_props,
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user