DEV Community

Discussion on: Create a Next.js RSS feed for your static website

_ndeyefatoudiop profile image
Ndeye Fatou Diop • Edited on

Thanks for the post. For those looking, you can validate the RSS feed generated here:

For those using Next.js with MDX files (located under src/pages), you can get the posts this way :

const globby = require("globby");
const fs = require("fs");
const path = require("path");
const frontmatter = require("@github-docs/frontmatter");

const getAllPostsXmlData = async () => {
  const pages = await globby([
  const posts = => {
    const fullPath = path.join(process.cwd(), page);
    const fileContents = fs.readFileSync(fullPath, "utf8");
    const matter = frontmatter(fileContents);
    return {, url: getPostUrl(page) };
  return posts;
Enter fullscreen mode Exit fullscreen mode