#RSS.xml.js returns `<title>ReferenceError</title>` with content collection content

2 messages · Page 1 of 1 (latest)

celest veldt
#

I'm trying to make an RSS feed for my site, loosly following the Add an RSS Feed guide. It says that include the post content, you need a third-party Markdown parser like Markdown-IT, but earlier today I used post.render() in content collections, which seemed to return plain HTML, so I tried to use that instead. Here is the file:

// rss.xml.js
import rss from "@astrojs/rss";
import { getCollection } from "astro:content";
renderedPost = await post.render()

export async function get() {
  const posts = await getCollection('blog');
  return rss({
    title: 'Southpaw1496',
    description: 'My Blog',
    site: 'https://southpaw1496.me/',
    items: posts.map((post) => ({
      title: post.data.title,
      pubDate: post.data.pubDate,
      description: post.data.description,
      link: `/blog/${post.slug}/`,
      content: renderedPost,
    })),
    customData: `<language>en-gb</language>`,
  });
};

When I try to use this file, running curl localhost:4321/rss.xml, it returns

<title>ReferenceError</title><script type="module" src="/@vite/client"></script>%

Why might this be happening?

Astro Documentation

Add an RSS feed to your Astro site to let users subscribe to your content.

fast rapidsBOT
#
Still waiting for an answer?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.