diff --git a/src/pages/changelog/rss/index.md.xml.ts b/src/pages/changelog/rss/index.md.xml.ts new file mode 100644 index 000000000000000..1735c23499d1048 --- /dev/null +++ b/src/pages/changelog/rss/index.md.xml.ts @@ -0,0 +1,22 @@ +import rss from "@astrojs/rss"; +import type { APIRoute } from "astro"; +import { getChangelogs, getRSSItems } from "~/util/changelog"; + +export const GET: APIRoute = async ({ locals }) => { + const notes = await getChangelogs({ + filter: (entry) => !entry.data.hidden, + }); + + const items = await getRSSItems({ + notes, + locals, + markdown: true, + }); + + return rss({ + title: "Cloudflare changelogs", + description: `Variant of the Cloudflare changelog with Markdown content rather than HTML`, + site: "https://developers.cloudflare.com/changelog/", + items, + }); +}; diff --git a/src/util/changelog.ts b/src/util/changelog.ts index 5b840f3802a9fe5..806d2b6dcfa314d 100644 --- a/src/util/changelog.ts +++ b/src/util/changelog.ts @@ -13,6 +13,9 @@ import rehypeParse from "rehype-parse"; import rehypeStringify from "rehype-stringify"; import rehypeBaseUrl from "~/plugins/rehype/base-url"; import rehypeFilterElements from "~/plugins/rehype/filter-elements"; +import remarkGfm from "remark-gfm"; +import rehypeRemark from "rehype-remark"; +import remarkStringify from "remark-stringify"; export type GetChangelogsOptions = { filter?: (entry: CollectionEntry<"changelog">) => boolean; @@ -68,7 +71,7 @@ type GetRSSItemsOptions = { */ locals: App.Locals; /** - * Returns Markdown in the `` field instead of HTML. + * Returns Markdown in the `` field instead of HTML. */ markdown?: boolean; }; @@ -76,6 +79,7 @@ type GetRSSItemsOptions = { export async function getRSSItems({ notes, locals, + markdown, }: GetRSSItemsOptions): Promise> { return await Promise.all( notes.map(async (note) => { @@ -90,9 +94,14 @@ export async function getRSSItems({ rehypeParse, rehypeBaseUrl, rehypeFilterElements, - rehypeStringify, ]; + if (markdown) { + plugins.push(remarkGfm, rehypeRemark, remarkStringify); + } else { + plugins.push(rehypeStringify); + } + const file = await unified() .data("settings", { fragment: true,