environment variables for port and filtering posts
This commit is contained in:
parent
35e3d595df
commit
e0ad3f29ae
@ -1,3 +1,4 @@
|
|||||||
|
use askama::filters::format;
|
||||||
use axum;
|
use axum;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
@ -22,9 +23,10 @@ async fn main() {
|
|||||||
// build our application with a single route
|
// build our application with a single route
|
||||||
let app = router::get_router();
|
let app = router::get_router();
|
||||||
// run our app with hyper, listening globally on port 3080
|
// run our app with hyper, listening globally on port 3080
|
||||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3080").await.unwrap();
|
let port = std::option_env!("PORT").unwrap_or("3080");
|
||||||
|
let addr = format!("0.0.0.0:{}", port);
|
||||||
|
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
|
||||||
axum::serve(listener, app).await.unwrap();
|
axum::serve(listener, app).await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Port from env variable
|
|
||||||
// TODO displaying Image from netlify CDN
|
// TODO displaying Image from netlify CDN
|
||||||
|
@ -37,7 +37,7 @@ pub async fn render_post_list(tag: Option<Path<String>>) -> Result<PostListTempl
|
|||||||
posts.push(post);
|
posts.push(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
let posts = match &tag {
|
let mut posts = match &tag {
|
||||||
Some(tag) => posts
|
Some(tag) => posts
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|post| {
|
.filter(|post| {
|
||||||
@ -52,6 +52,16 @@ pub async fn render_post_list(tag: Option<Path<String>>) -> Result<PostListTempl
|
|||||||
None => posts,
|
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 {
|
Ok(PostListTemplate {
|
||||||
title: "Posts".to_owned(),
|
title: "Posts".to_owned(),
|
||||||
posts,
|
posts,
|
||||||
|
@ -19,4 +19,4 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{# <ArticlePreviewList {...data} segment="blog" /> #} {% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user