{"id":19701320,"url":"https://github.com/ddamato/astro-mdx-rss","last_synced_at":"2026-05-10T12:53:10.797Z","repository":{"id":231456919,"uuid":"781743604","full_name":"ddamato/astro-mdx-rss","owner":"ddamato","description":"Implementation to render Astro MDX into RSS feed","archived":false,"fork":false,"pushed_at":"2024-04-04T14:11:59.000Z","size":311,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-10T10:58:02.772Z","etag":null,"topics":["astro","mdx","rss"],"latest_commit_sha":null,"homepage":"https://ddamato.github.io/astro-mdx-rss/","language":"Astro","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddamato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-04T00:23:40.000Z","updated_at":"2024-09-19T15:50:09.000Z","dependencies_parsed_at":"2025-01-10T11:06:41.312Z","dependency_job_id":null,"html_url":"https://github.com/ddamato/astro-mdx-rss","commit_stats":null,"previous_names":["ddamato/astro-mdx-rss"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddamato%2Fastro-mdx-rss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddamato%2Fastro-mdx-rss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddamato%2Fastro-mdx-rss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddamato%2Fastro-mdx-rss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddamato","download_url":"https://codeload.github.com/ddamato/astro-mdx-rss/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241014883,"owners_count":19894318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astro","mdx","rss"],"created_at":"2024-11-11T21:08:36.006Z","updated_at":"2026-05-10T12:53:05.772Z","avatar_url":"https://github.com/ddamato.png","language":"Astro","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Astro MDX RSS Starter\n\n\u003e [!WARNING]\n\u003e This doesn't work as a built site, but it does work in local dev. I have an [open proposal](https://github.com/withastro/roadmap/discussions/881) to help this concept along and potentially omit the need for `rss.xml.js` as a proxy for the resulting XML.\n\nCheck out the example by visiting [https://ddamato.github.io/astro-mdx-rss/rss.xml](https://ddamato.github.io/astro-mdx-rss/rss.xml)\n\nDid you expect to render MDX posts into your RSS feed with Astro, only to find out that you can only render MDX in `.astro` files? Yep, me too.\n\nAstro is working on the [Container API](https://github.com/withastro/roadmap/issues/533) which is expected to solve the problem. In the meantime, you can consider this repo which uses Astro's blog starter as the base with a few updates.\n\n- Add `mdx` integration.\n- All content files are `.mdx`.\n- Added `/pages/rss.astro`.\n\n## `pages/rss.xml.js`\n\nInstead of using `@astrojs/rss` to create the RSS feed, we're going to take the response from the new `/pages/rss.astro` file and send it out with a new header.\n\n```js\nexport async function GET(context) {\n  const endpoint = new URL('/rss', context.url.origin);\n  const xml = await fetch(endpoint).then((res) =\u003e res.text());\n  return new Response(xml, {\n    status: 200,\n    headers: new Headers({ 'Content-type': 'text/xml;charset=UTF-8' })\n  });\n}\n```\n\n- The `/rss` route points to the `/rss` page (more specifically, `/pages/rss.astro`).\n- We get the response text from that request, and set it as the body of the upcoming response.\n- We add the `'Content-type: text/xml;charset=UTF-8'` header to let the browser know this is XML.\n\n## `/pages/rss.astro`\n\nThis page builds the RSS feed and it has a few gotchas.\n\n```.astro\n---\nexport const partial = true;\nimport { getCollection } from 'astro:content';\nimport { SITE_TITLE, SITE_DESCRIPTION } from '../consts';\nconst posts = await getCollection('blog');\n---\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003crss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\u003e\n  \u003cchannel\u003e\n    \u003ctitle\u003e{ SITE_TITLE }\u003c/title\u003e\n    \u003cdescription\u003e{ SITE_DESCRIPTION }\u003c/description\u003e\n    \u003cFragment set:html={ `\u003clink\u003e${ Astro.url.origin }\u003c/link\u003e` }/\u003e\n  \u003c/channel\u003e\n  { posts.map(async (post) =\u003e {\n    const url = new URL(`blog/${post.slug}`, Astro.url.origin).toString();\n    const { Content } = await post.render();\n    return (\n      \u003citem\u003e\n        \u003ctitle\u003e{post.data.title}\u003c/title\u003e\n        \u003cFragment set:html={ `\u003clink\u003e${ url }\u003c/link\u003e` }/\u003e\n        \u003cguid\u003e{ url }\u003c/guid\u003e\n        \u003cdescription\u003e{ post.data.description }\u003c/description\u003e\n        \u003cpubDate\u003e{ post.data.pubDate }\u003c/pubDate\u003e\n          \u003cFragment is:raw\u003e\n            \u003ccontent:encoded\u003e\u003c![CDATA[\n          \u003c/Fragment\u003e\n          \u003cContent/\u003e\n          \u003cFragment is:raw\u003e\n            ]]\u003e\u003c/content:encoded\u003e\n          \u003c/Fragment\u003e\n      \u003c/item\u003e\n    )\n  }) }\n\u003c/rss\u003e\n```\n\n- The `export const partial = true;` tells Astro to _not_ add the expected `\u003chtml\u003e`, `\u003chead\u003e`, and `\u003cbody\u003e` tags and to treat this as an [HTML partial](https://docs.astro.build/en/basics/astro-pages/#page-partials).\n- The `\u003cFragment set:html={ `\u003clink\u003e${ Astro.url.origin }\u003c/link\u003e` }/\u003e` is needed because Astro considers `\u003clink\u003e` to be a self-closing tag and won't render the ending tag causing the feed to be invalid. We circumvent this by writing the HTML using `set:html` in a `\u003cFragment/\u003e`.\n- The whole purpose of this is the `\u003cContent/\u003e` element, which _must_ be rendered in an `.astro` file. We flank both sides with `\u003cFragment is:raw\u003e` elements which tells Astro not to process anything between the `\u003cFragment/\u003e` tags. This allows the `\u003ccontent:encoding\u003e` and `CDATA` to render as a string.\n\n\u003e [!NOTE]\n\u003e Hitting `/rss` in the browser does not provide an XML response, but an HTML one. So mileage may vary about how valid that appears to syndication.\n\nAnd now hitting `/rss.xml` should provide a fully qualified RSS feed with rendered MDX! You'll most likely need to update the `/pages/rss.astro` file for a more detailed feed.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddamato%2Fastro-mdx-rss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddamato%2Fastro-mdx-rss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddamato%2Fastro-mdx-rss/lists"}