This commit is contained in:
parent
96ead1a38f
commit
fec60900f5
@ -26,6 +26,7 @@ rayon = "1.10.0"
|
|||||||
syntect = "5.2.0"
|
syntect = "5.2.0"
|
||||||
indoc = "2.0.5"
|
indoc = "2.0.5"
|
||||||
askama_escape = "0.10.3"
|
askama_escape = "0.10.3"
|
||||||
|
mime_guess = "2.0.5"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
rustflags = ["-Z", "threads=8"]
|
rustflags = ["-Z", "threads=8"]
|
||||||
|
20
src/feed.rs
20
src/feed.rs
@ -1,7 +1,7 @@
|
|||||||
use axum::http::{header, StatusCode};
|
use axum::http::{header, StatusCode};
|
||||||
use axum::response::IntoResponse;
|
use axum::response::IntoResponse;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use rss::{ChannelBuilder, GuidBuilder, Item, ItemBuilder};
|
use rss::{ChannelBuilder, EnclosureBuilder, GuidBuilder, Item, ItemBuilder};
|
||||||
|
|
||||||
use crate::blog_posts::blog_post_model::{BlogPostMetadata, BLOG_POST_PATH};
|
use crate::blog_posts::blog_post_model::{BlogPostMetadata, BLOG_POST_PATH};
|
||||||
use crate::filters::{parse_markdown, truncate_md};
|
use crate::filters::{parse_markdown, truncate_md};
|
||||||
@ -26,7 +26,6 @@ pub async fn render_rss_feed() -> Result<impl IntoResponse, StatusCode> {
|
|||||||
ItemBuilder::default()
|
ItemBuilder::default()
|
||||||
.title(Some(post.metadata.title))
|
.title(Some(post.metadata.title))
|
||||||
.link(Some(format!("https://michalvanko.dev/blog/{}", post.slug)))
|
.link(Some(format!("https://michalvanko.dev/blog/{}", post.slug)))
|
||||||
// TODO Description should be just a preview
|
|
||||||
.description({
|
.description({
|
||||||
let truncated =
|
let truncated =
|
||||||
truncate_md(&post.body, 2).unwrap_or("Can't parse post body".to_string());
|
truncate_md(&post.body, 2).unwrap_or("Can't parse post body".to_string());
|
||||||
@ -34,6 +33,23 @@ pub async fn render_rss_feed() -> Result<impl IntoResponse, StatusCode> {
|
|||||||
.unwrap_or("Can't process truncated post body".to_string());
|
.unwrap_or("Can't process truncated post body".to_string());
|
||||||
Some(parsed_md)
|
Some(parsed_md)
|
||||||
})
|
})
|
||||||
|
.content({
|
||||||
|
let parsed_md = parse_markdown(&post.body)
|
||||||
|
.unwrap_or("Can't process full post body".to_string());
|
||||||
|
Some(parsed_md)
|
||||||
|
})
|
||||||
|
.enclosure({
|
||||||
|
post.metadata.thumbnail.map(|src| {
|
||||||
|
let mime_type = mime_guess::from_path(&src)
|
||||||
|
.first()
|
||||||
|
.map(|mime| mime.to_string())
|
||||||
|
.unwrap_or("image".to_string());
|
||||||
|
EnclosureBuilder::default()
|
||||||
|
.url(src)
|
||||||
|
.mime_type(mime_type)
|
||||||
|
.build()
|
||||||
|
})
|
||||||
|
})
|
||||||
.guid(Some(
|
.guid(Some(
|
||||||
GuidBuilder::default()
|
GuidBuilder::default()
|
||||||
.value(format!("https://michalvanko.dev/blog/{}", post.slug))
|
.value(format!("https://michalvanko.dev/blog/{}", post.slug))
|
||||||
|
Loading…
Reference in New Issue
Block a user