aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/feed.json.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/feed.json.ts')
-rw-r--r--src/pages/feed.json.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pages/feed.json.ts b/src/pages/feed.json.ts
new file mode 100644
index 0000000..e155022
--- /dev/null
+++ b/src/pages/feed.json.ts
@@ -0,0 +1,22 @@
+import type { GetServerSideProps } from 'next';
+import { generateFeed } from '../utils/helpers';
+
+const Feed = () => null;
+
+export const getServerSideProps: GetServerSideProps = async ({ res }) => {
+ const feed = await generateFeed();
+
+ res.setHeader(
+ 'Cache-Control',
+ 'public, s-maxage=600, stale-while-revalidate=59'
+ );
+ res.setHeader('Content-Type', 'application/json');
+ res.write(feed.json1());
+ res.end();
+
+ return {
+ props: {},
+ };
+};
+
+export default Feed;