feat(blog) add cover images to RSS via <enclosure>

This commit is contained in:
Monty 2021-09-29 15:59:07 +02:00
parent d9a98edb21
commit 41e7d8c810
No known key found for this signature in database
GPG Key ID: 78B405B6520E1012
2 changed files with 3 additions and 1 deletions

View File

@ -49,9 +49,10 @@ router.get('/', async (request, response) => {
// RSS feed
router.get('/feed.xml', async (request, response) => {
// Adds the pubDate to the post array
// Adds the pubDate and the cover_extension to the post array
const posts = postList().map((post) => {
post.postInfo.pubDate = new Date(post.postInfo.date).toUTCString();
post.postInfo.cover_extension = post.postInfo.cover_image.substring(post.postInfo.cover_image.lastIndexOf('.') + 1);
return post;
});

View File

@ -22,6 +22,7 @@
<link>https://pretendo.network/blog/{{this.slug}}</link>
<guid>https://pretendo.network/blog/{{this.slug}}</guid>
<pubDate>{{ this.postInfo.pubDate }}</pubDate>
<enclosure url="{{ this.postInfo.cover_image }}" length="0" type="image/{{ this.postInfo.cover_extension }}"/>
</item>
{{/each}}