Skip to content

Instantly share code, notes, and snippets.

@arkmuntasser
Created April 13, 2021 02:31
Show Gist options
  • Save arkmuntasser/7d73909b3c7d7cc8f61c915f1df1b65f to your computer and use it in GitHub Desktop.
Save arkmuntasser/7d73909b3c7d7cc8f61c915f1df1b65f to your computer and use it in GitHub Desktop.
Generate an RSS feed for a Next-MDX blog
const fs = require('fs')
const RSS = require('rss')
const { getAllNodes } = require('next-mdx');
const feed = new RSS({
title: 'My Blog',
site_url: 'https://my-blog.com'
});
const posts = await getAllNodes('post');
posts.forEach(post => {
feed.item({
title: post.frontMatter.title,
guid: post.slug,
url: `https://my-blog.com/post/${post.url}`,
date: post.frontMatter.date
});
});
const xml = feed.xml({ indent: true });
fx.writeFileSync('public/rss.xml', xml);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment