From a32f7b146c216f4159f65d5c0b9a7189d31b2f5a Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Thu, 13 Jan 2022 18:15:41 +0100
Subject: chore: add different feed formats (feed.xml, atom.xml, feed.json)

---
 src/pages/feed.xml.tsx | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 src/pages/feed.xml.tsx

(limited to 'src/pages/feed.xml.tsx')

diff --git a/src/pages/feed.xml.tsx b/src/pages/feed.xml.tsx
new file mode 100644
index 0000000..093cab8
--- /dev/null
+++ b/src/pages/feed.xml.tsx
@@ -0,0 +1,20 @@
+import { generateFeed } from '@utils/helpers/rss';
+import { GetServerSideProps } from 'next';
+
+const Feed = () => null;
+
+export const getServerSideProps: GetServerSideProps = async ({ res }) => {
+  const feed = await generateFeed();
+
+  if (res) {
+    res.setHeader('Content-Type', 'text/xml');
+    res.write(`${feed.rss2()}`);
+    res.end();
+  }
+
+  return {
+    props: {},
+  };
+};
+
+export default Feed;
-- 
cgit v1.2.3

