Reputation: 101
I have a blog
page living under app/[locale]/home/blog/page.tsx
.
import glob from 'fast-glob'
import path from 'path'
const BlogPage = async () => {
let pages = await glob('**/*.mdx', {
cwd: `${path.resolve()}/app/[locale]/home/blog`,
})
return (
<></>
)
}
export default BlogPage
The pages array bring the information for my mdx
files under app/[locale]/home/blog/**/*.mdx
. It does fetch my blog pages in development, but it DOES NOT find the pages in production. The pages array just comes empty { pages: [] }
if i console.log({ pages })
, but i get them in development.
I did try to escape the brackets in app/\[locale\]/...
but didn't work. I trie also using process.pwd()
and also path.resolve()
and neither of those worked.
Upvotes: 0
Views: 207
Reputation: 23
I had similar problem, but instead of fast-glob
library i used glob
.
I think they both use regex under the hood, so instead of escaping app/\[locale\]/...
like this, you need to use double backslashes. Like this app/\\[locale\\]/...
. This solved it for me.
Here's explanation
Upvotes: 1