Skip to content

Commit d632fd8

Browse files
committed
feat(rss): include cover images as enclosures
Use getPostImage to resolve cover images for each post and include them as RSS enclosure elements. Falls back to default cover if no custom cover.png exists.
1 parent d6104f5 commit d632fd8

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

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)