Try adding images to rss feed

This commit is contained in:
Anton Pogrebnjak
2026-05-29 19:49:06 +02:00
parent 01674e03f4
commit da0d7f239c
+28 -4
View File
@@ -6,13 +6,37 @@ export async function GET(context) {
const posts = await getCollection('blog'); const posts = await getCollection('blog');
const projects = await getCollection('projects'); const projects = await getCollection('projects');
let unifiedItems = posts.map((post) => ({ let unifiedItems = posts.map((post) => {
let item = {
...post.data, ...post.data,
link: `/blog/${post.id}/`, link: `/blog/${post.id}/`,
})).concat(projects.map((project) => ({ };
if (post.data.heroImage) {
item.enclosure = {
url: post.data.heroImage.src,
length: post.data.heroImage.width * post.data.heroImage.height,
type: `image/${post.data.heroImage.format}`
}
}
return item;
}).concat(projects.map((project) => {
let item = {
...project.data, ...project.data,
link: `/projects/${project.id}/` link: `/projects/${project.id}/`,
}))); };
if (project.heroImage) {
item.enclosure = {
url: project.data.heroImage.src,
length: project.data.heroImage.width * project.data.heroImage.height,
type: `image/${project.data.heroImage.format}`
}
}
return item;
}));
unifiedItems = unifiedItems.sort((a, b) => b.pubDate - a.pubDate); unifiedItems = unifiedItems.sort((a, b) => b.pubDate - a.pubDate);
return rss({ return rss({