I have multiple React files in a folder:
content
- blog-post-1.jsx
- blog-post-2.jsx
- blog-post-3.jsx
I now want to go through the files in this folder and extract the frontmatter of each file. I was thinking of exporting a javascript object from each file, e.g.:
// e.g.: blog-post-1.jsx
export const frontmatter = {
title: "My Title",
published: "02/12/2024"
}
But I am stuck here: How could I map through the folder and automatically grab the frontmatter object from each file, without knowing the exact number of files in the content
folder?