-
Hey Remix community! 👋 I'm refactoring my blog to Remix, and it's a crazy, but wonderful journey! My posts are MDX files, and I'm using mdx-bundler to compile them. So these files are not located in Initially I put them in the However, by putting them outside of Thanks! EDIT: This relates to #1492 that has just been posted 😄 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
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;
} |
Beta Was this translation helpful? Give feedback.
-
How can we do this on Remix v2? __dirname is undefined on node 18 |
Beta Was this translation helpful? Give feedback.
make your Posts function like this I solve this problem and its work for me on vercel