summaryrefslogtreecommitdiff
path: root/apps/web/src/app/rss.xml/route.ts
diff options
context:
space:
mode:
authorTaqib <taqib.ibrahim@gmail.com>2025-07-23 15:11:10 +0100
committerTaqib <taqib.ibrahim@gmail.com>2025-07-23 15:11:10 +0100
commit57243bc4b4d28e80e42ec70e3656e5a94c8407e2 (patch)
treeb0d025527b3148c05e650f3a6890780902e0e376 /apps/web/src/app/rss.xml/route.ts
parentcabf86033032f0a396569cce9165cd656be791d6 (diff)
downloadopencut-57243bc4b4d28e80e42ec70e3656e5a94c8407e2.tar.gz
feat: add an rss feed
Diffstat (limited to 'apps/web/src/app/rss.xml/route.ts')
-rw-r--r--apps/web/src/app/rss.xml/route.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/apps/web/src/app/rss.xml/route.ts b/apps/web/src/app/rss.xml/route.ts
new file mode 100644
index 00000000..1567d4a7
--- /dev/null
+++ b/apps/web/src/app/rss.xml/route.ts
@@ -0,0 +1,40 @@
+import { Feed } from 'feed';
+import { getPosts } from '@/lib/blog-query';
+import { SITE_INFO } from '../metadata';
+
+export async function GET() {
+ const { posts } = await getPosts();
+
+ const feed = new Feed({
+ title: 'OpenCut Blog',
+ description: SITE_INFO.description,
+ id: `${SITE_INFO.url}`,
+ link: `${SITE_INFO.url}/blog/`,
+ language: 'en',
+ image: `${SITE_INFO.openGraphImage}`,
+ favicon: `${SITE_INFO.favicon}`,
+ copyright: `All rights reserved ${new Date().getFullYear()}, ${
+ SITE_INFO.title
+ }`,
+ });
+
+ posts.forEach((article) => {
+ feed.addItem({
+ title: article.title,
+ id: `${SITE_INFO.url}/blog/${article.slug}`,
+ link: `${SITE_INFO.url}/blog/${article.slug}`,
+ description: article.description,
+ author: article.authors.map((author) => ({
+ name: author.name ?? 'OpenCut',
+ })),
+ date: new Date(article.publishedAt),
+ image: article.coverImage,
+ });
+ });
+
+ return new Response(feed.rss2(), {
+ headers: {
+ 'Content-Type': 'text/xml',
+ },
+ });
+} \ No newline at end of file