Skip to content

Commit

Permalink
Add images to RSS feed
Browse files Browse the repository at this point in the history
Signed-off-by: Milan Gruner <[email protected]>
  • Loading branch information
lemilonkh committed Sep 17, 2023
1 parent 159a7ed commit 8221d68
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/pages/rss.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ interface Item {
title?: string;
name?: string;
description: string;
image?: {
url?: string;
src?: string;
format?: string;
alt?: string;
};
date: Date;
customData?: string;
};
Expand Down Expand Up @@ -39,6 +45,11 @@ export const GET: APIRoute = async (context) => {
customData: item.data.customData,
link: `/${item.type}/${item.slug}`,
content: sanitizeHtml(parser.render(item.body)),
enclosure: item.data.image ? {
url: item.data.image.url || item.data.image.src || 'https://gruner.tech/favicon.svg',
type: item.data.image.format ? `image/${item.data.image.format}` : 'image/png',
length: 0,
} : undefined,
}));

return rss({
Expand Down

0 comments on commit 8221d68

Please sign in to comment.