Proxigram/src/pages/[username]/stories/rss.tsx
2024-01-03 13:11:37 +00:00

28 linhas
616 B
TypeScript

import { GetServerSidePropsContext } from "next";
import { RSS } from "@/utils/rss";
import { env } from "env.mjs";
export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
if (!env.RSS) {
ctx.res.write("RSS is disabled");
ctx.res.end();
return {
props: {},
};
}
const username = ctx.params?.username as string;
const rss = new RSS();
const feedString = await rss.getStories(username);
ctx.res.setHeader("Content-Type", "text/xml");
ctx.res.write(feedString);
ctx.res.end();
return {
props: {},
};
};
const RSSStoriesPage = () => null;
export default RSSStoriesPage;