Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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