From 8221d6835953e6e521e8dc349b05956999a9cabf Mon Sep 17 00:00:00 2001 From: Milan Gruner Date: Sun, 17 Sep 2023 15:19:17 +0200 Subject: [PATCH] Add images to RSS feed Signed-off-by: Milan Gruner --- src/pages/rss.xml.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts index 07325ca..7502175 100644 --- a/src/pages/rss.xml.ts +++ b/src/pages/rss.xml.ts @@ -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; }; @@ -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({