Open Patrik-Tkacik opened 4 months ago
Hey there. Indeed i'm having the same issue with the same template, although I rolled custom internalization the issue stays the same. Imported MDX content doesn't translate (if you try wrap items in t() you get undefined on vercel prod environment, but works fine on my local dev environment. However, doing the same but without t() works just fine. Most likely I'll walk away from mdx in this case.
I'm curious if you made any progress debugging this?
I’ve put the project on pause as I have no way to track whats wrong effectively. My issue was with static/dynamic paths, I think. Not with mdx files not translating. What alternative will you use @Guccifer808?
@Patrik-Tkacik I've switched from .mdx to an array of objects works flawlessly.
My issue was with static/dynamic paths, I think. Not with .mdx files not translating
According to my tests .mdx in defined and renders fine in prod, it's the object inside it that returns undefined in prod. Thus, dynamic paths (in my case app/[lang]/) were not an issue. Moreover, all other parts of the app have no issues, only objects inside .mdx
Hi, any luck with the solution?
It's not working for me as well. Everything works well on local dev but on production, it doesn't loads the content of .mdx file. Moreover, it doesn't produce any error so it is hard to understand what's wrong.
@Guccifer808 so you made a static array instead of dynamically fetching it?
@G0rav Hey, sorry no. Still have the project on hold, I haven't been experimenting with it. have my hands full of work on some other stuff.
@Guccifer808 so you made a static array instead of dynamically fetching it?
I made loader similar to mdxloader just migrated to array of objects:
import { allBrandsData, brandsNames } from '@/data/allBrandsData'
/**
Invalid parameter: ${type}. Expected 'data' or 'names'.
)
return null
}
} catch (error) {
console.error(Error loading brand data: ${error.message}
)
throw error
}
}
Link to the code that reproduces this issue
https://github.com/Patrik-Tkacik/Nextjs-reproduction
To Reproduce
Clone the repository,![Screenshot 2024-05-05 at 17 48 31](https://github.com/vercel/next.js/assets/157832795/ffb2f804-0972-46e1-aa8e-3d094ccae19f)
npm install
and runnpm run dev
, go on the root/localized pag e which will most likely be /en for you, and check out the CaseStudies function, on localhost, whether you're running dev mode or build it and start it, it works. This is how it should look like:now check it out from my vercel hosted app here.
Current vs. Expected behavior
Those projects you see in the CaseStudies function, are individual MDX pages that get collected by the lib/mdx.ts file. That should give the data to all components and it does, it also gives the info to make the pages. Now my issue is when running this in production it generates the mdx pages into normal tsx pages no problem, but it doesn't give the data to the components like CaseStudies. When I debugged it a little it was because the CaseStudies function doesn't get anything in the array. I have found a stackoverflow answer which I hoped would help me, because it worked fine before I localized this project (I modified a template) so I thought that was it but it cant be, maybe its glob, maybe its mdx, it doesn't make sense to me. The stackoverflow indicated the blob is the issue, but it didnt have any issues giving data to generate the static pages at build time on vercel. What could it be?
Provide environment information
Which area(s) are affected? (Select all that apply)
Developer Experience, Internationalization (i18n), Markdown (MDX), Runtime
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
Additional context
No response