So from what I know, deploying to serverless environment like Vercel or Netlify won't have these local files available. Some solution I found online is to configure Vite to copy the markdown files to output directory during build process but I still couldn't manage to do it. Then my second approach is to prerender all routes that need reading local markdown files.
But problem is prerender gives me error at build time too, and the error message is not very clear of why it happened. In the attempt to recreate the error, I found that prerender only gives me error if I try to read local markdown files with search params. Without search params it's all good. Here's all the code that I think we all need to debug. Note that the markdown file does exist there.