aboutsummaryrefslogtreecommitdiffstats
path: root/src/pages/atom.xml.tsx
blob: 79813d19835ec069be7d95a57e1d01942fbf8b03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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(
      'Cache-Control',
      'public, s-maxage=600, stale-while-revalidate=59'
    );
    res.setHeader('Content-Type', 'text/xml');
    res.write(`${feed.atom1()}`);
    res.end();
  }

  return {
    props: {},
  };
};

export default Feed;