environment variables for port and filtering posts

This commit is contained in:
2024-01-18 20:53:39 +01:00
parent 35e3d595df
commit e0ad3f29ae
3 changed files with 16 additions and 4 deletions

View File

@ -37,7 +37,7 @@ pub async fn render_post_list(tag: Option<Path<String>>) -> Result<PostListTempl
posts.push(post);
}
let posts = match &tag {
let mut posts = match &tag {
Some(tag) => posts
.into_iter()
.filter(|post| {
@ -52,6 +52,16 @@ pub async fn render_post_list(tag: Option<Path<String>>) -> Result<PostListTempl
None => posts,
};
if std::env::var("TARGET")
.unwrap_or_else(|_| "DEV".to_owned())
.eq("PROD")
{
posts = posts
.into_iter()
.filter(|post| !post.slug.starts_with("dev"))
.collect()
}
Ok(PostListTemplate {
title: "Posts".to_owned(),
posts,