Skip to content
Discussion options

You must be logged in to vote

make your Posts function like this I solve this problem and its work for me on vercel

export async function getPosts() {
  const postsPath = await fs.readdir(
    `${__dirname}/../../app/posts`,
    { withFileTypes: true }
  );

  const posts = await Promise.all(
    postsPath
      .map(async (dirent) => {
        const file = await fs.readFile(
          path.join(`${__dirname}/../../app/posts`, dirent.name)
        );
        const { attributes } = parseFrontMatter(file.toString());
        return {
          slug: dirent.name.replace(/\.mdx/, ""),
          title: attributes.title,
        };
      })
  );

  return posts;
}

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@silvenon
Comment options

@cagarweyne
Comment options

Answer selected by silvenon
Comment options

You must be logged in to vote
1 reply
@kiliman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants