Try adding images to rss feed
This commit is contained in:
+31
-7
@@ -6,13 +6,37 @@ export async function GET(context) {
|
||||
const posts = await getCollection('blog');
|
||||
const projects = await getCollection('projects');
|
||||
|
||||
let unifiedItems = posts.map((post) => ({
|
||||
...post.data,
|
||||
link: `/blog/${post.id}/`,
|
||||
})).concat(projects.map((project) => ({
|
||||
...project.data,
|
||||
link: `/projects/${project.id}/`
|
||||
})));
|
||||
let unifiedItems = posts.map((post) => {
|
||||
let item = {
|
||||
...post.data,
|
||||
link: `/blog/${post.id}/`,
|
||||
};
|
||||
|
||||
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,
|
||||
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);
|
||||
|
||||
return rss({
|
||||
|
||||
Reference in New Issue
Block a user