File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 1+ import rss from "@astrojs/rss" ;
2+ import type { APIRoute } from "astro" ;
3+ import { getChangelogs , getRSSItems } from "~/util/changelog" ;
4+
5+ export const GET : APIRoute = async ( { locals } ) => {
6+ const notes = await getChangelogs ( {
7+ filter : ( entry ) => ! entry . data . hidden ,
8+ } ) ;
9+
10+ const items = await getRSSItems ( {
11+ notes,
12+ locals,
13+ markdown : true ,
14+ } ) ;
15+
16+ return rss ( {
17+ title : "Cloudflare changelogs" ,
18+ description : `Variant of the Cloudflare changelog with Markdown content rather than HTML` ,
19+ site : "https://developers.cloudflare.com/changelog/" ,
20+ items,
21+ } ) ;
22+ } ;
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ import rehypeParse from "rehype-parse";
1313import rehypeStringify from "rehype-stringify" ;
1414import rehypeBaseUrl from "~/plugins/rehype/base-url" ;
1515import rehypeFilterElements from "~/plugins/rehype/filter-elements" ;
16+ import remarkGfm from "remark-gfm" ;
17+ import rehypeRemark from "rehype-remark" ;
18+ import remarkStringify from "remark-stringify" ;
1619
1720export type GetChangelogsOptions = {
1821 filter ?: ( entry : CollectionEntry < "changelog" > ) => boolean ;
@@ -68,14 +71,15 @@ type GetRSSItemsOptions = {
6871 */
6972 locals : App . Locals ;
7073 /**
71- * Returns Markdown in the `<content:encoded >` field instead of HTML.
74+ * Returns Markdown in the `<description >` field instead of HTML.
7275 */
7376 markdown ?: boolean ;
7477} ;
7578
7679export async function getRSSItems ( {
7780 notes,
7881 locals,
82+ markdown,
7983} : GetRSSItemsOptions ) : Promise < Array < RSSFeedItem > > {
8084 return await Promise . all (
8185 notes . map ( async ( note ) => {
@@ -90,9 +94,14 @@ export async function getRSSItems({
9094 rehypeParse ,
9195 rehypeBaseUrl ,
9296 rehypeFilterElements ,
93- rehypeStringify ,
9497 ] ;
9598
99+ if ( markdown ) {
100+ plugins . push ( remarkGfm , rehypeRemark , remarkStringify ) ;
101+ } else {
102+ plugins . push ( rehypeStringify ) ;
103+ }
104+
96105 const file = await unified ( )
97106 . data ( "settings" , {
98107 fragment : true ,
You can’t perform that action at this time.
0 commit comments