Skip to content

Commit 18ef57b

Browse files
authored
feat(rss): include cover images as enclosures (#43)
1 parent d6104f5 commit 18ef57b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/pages/rss.xml.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { getCollection } from 'astro:content';
33
import type { APIContext } from 'astro';
44
import sanitizeHtml from 'sanitize-html';
55
import MarkdownIt from 'markdown-it';
6+
import { getPostImage } from '../lib/posts';
67

78
const parser = new MarkdownIt();
89

@@ -49,13 +50,12 @@ export async function GET(context: APIContext) {
4950
}),
5051
};
5152

52-
if (post.data.image) {
53-
item.enclosure = {
54-
url: `${site}${post.data.image.src}`,
55-
type: getMimeType(post.data.image.src),
56-
length: 0,
57-
};
58-
}
53+
const image = getPostImage(post);
54+
item.enclosure = {
55+
url: `${site}${image.src}`,
56+
type: getMimeType(image.src),
57+
length: 0,
58+
};
5959

6060
// Add custom data for bluesky post ID if present
6161
if (post.data.blueskyPostId) {

0 commit comments

Comments
 (0)