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 posts = await getCollection('blog');
|
||||||
const projects = await getCollection('projects');
|
const projects = await getCollection('projects');
|
||||||
|
|
||||||
let unifiedItems = posts.map((post) => ({
|
let unifiedItems = posts.map((post) => {
|
||||||
...post.data,
|
let item = {
|
||||||
link: `/blog/${post.id}/`,
|
...post.data,
|
||||||
})).concat(projects.map((project) => ({
|
link: `/blog/${post.id}/`,
|
||||||
...project.data,
|
};
|
||||||
link: `/projects/${project.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);
|
unifiedItems = unifiedItems.sort((a, b) => b.pubDate - a.pubDate);
|
||||||
|
|
||||||
return rss({
|
return rss({
|
||||||
|
|||||||
Reference in New Issue
Block a user