Skip to content

Commit d98d3a5

Browse files
authored
Attempt fix rss.xml.js
1 parent 526cad7 commit d98d3a5

1 file changed

Lines changed: 29 additions & 24 deletions

File tree

src/pages/rss.xml.js

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
1-
import rss from "@astrojs/rss";
2-
import { getCollection } from "astro:content";
3-
41
export async function GET(context) {
52
const blog = await getCollection("blog");
63

4+
const items = await Promise.all(
5+
blog.map(async (post) => {
6+
const { html } = await post.render();
7+
8+
return {
9+
title: post.data.title,
10+
pubDate: post.data.pubDate,
11+
description: post.data.description,
12+
link: `/blog/${post.slug}/`,
13+
content: html,
14+
categories: post.data.tags || [],
15+
author: "CuddlyBunion341",
16+
guid: post.slug,
17+
...(post.data.heroImage && {
18+
enclosure: {
19+
url: post.data.heroImage,
20+
type: "image/jpeg",
21+
length: 0,
22+
},
23+
}),
24+
customData: `
25+
<tags>${(post.data.tags || []).map((tag) => `<tag>${tag}</tag>`).join("")}</tags>
26+
<license>MIT</license>
27+
`,
28+
};
29+
})
30+
);
31+
732
return rss({
833
title: "CuddlyBunion341 Blog",
934
description: "Personal blog and portfolio",
@@ -13,26 +38,6 @@ export async function GET(context) {
1338
lastBuildDate: new Date(),
1439
ttl: 60,
1540
customData: `<generator>Astro v4</generator>`,
16-
items: blog.map((post) => ({
17-
title: post.data.title,
18-
pubDate: post.data.pubDate,
19-
description: post.data.description,
20-
link: `/blog/${post.slug}/`,
21-
content: post.body,
22-
categories: post.data.tags || [],
23-
author: "CuddlyBunion341",
24-
guid: post.slug,
25-
...(post.data.heroImage && {
26-
enclosure: {
27-
url: post.data.heroImage,
28-
type: "image/jpeg",
29-
length: 0,
30-
},
31-
}),
32-
customData: `
33-
<tags>${(post.data.tags || []).map((tag) => `<tag>${tag}</tag>`).join("")}</tags>
34-
<license>MIT</license>
35-
`,
36-
})),
41+
items,
3742
});
3843
}

0 commit comments

Comments
 (0)