-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collections - generating page for MDX page fails #5703
Comments
Have you found any solution for this @thomasledoux1 ? I have the same problem with mdx, but it works fine on Astro Example. Not sure what's making the issue here. |
@surjithctly I didn't find it yet. |
I'm also getting an error in development if I used Here's a related issue with the space in parent folder: #5598 |
Thanks for sharing @thomasledoux1! Looks like an issue with escaping content of the MDX body. Can you send a minimal example on Stackblitz with the contents of Also to clarify, is this an issue with spaces in the path to your project? This is being tracked separately as @surjithctly noted. |
Hi @bholmesdev, thanks for getting back on this! |
Does this only happen with Content Collections or does it happen if the mdx file is just a normal page? |
@matthewp only happens with Content Collections, as a normal page it works fine |
@matthewp It's likely from the way we stringify the raw MDX body here. We do not expose the raw content in the regular MDX plugin. Maybe we need stronger serialization for MDX? |
I'm confused, this Stackblitz doesn't use content collections. What am I missing @thomasledoux1 ? |
@matthewp I just created a minimal reproduction with the MDX file in it as asked by @bholmesdev. If you want I can change the current Stackblitz, but I'm not sure if it's going to help a lot, since the error only occurs at build time? Not sure if you can run the build command in Stackblitz? |
@thomasledoux1 I can pull it down and run the build locally. Just having something that breaks is super helpful, thank you! |
Was able to reduce it down to being about the
Will do some more investigation. |
Not able to recreate with this example: https://stackblitz.com/edit/github-kbdjml?file=astro.config.mjs,src%2Fpages%2Findex.astro,src%2Fcontent%2Fconfig.ts,src%2Fcontent%2Fblog%2Fone.mdx&on=stackblitz My assumption is there is something else with your config causing this. |
My Astro.config.js looks like this if relevant: import { defineConfig } from 'astro/config'; // https://astro.build/config |
It's Vercel Edge that's causing it. Doesn't break with any other adapters: Now going to see if mdx matters or not. |
MDX does not matter. Also this is not related to content collections. Happens with a normal page too: |
This workaround fixes it:
In your astro.config file. |
This is a bug in Vite, see vitejs/vite#9829 Probably won't keep this issue open since it's an upstream issue. cc @bluwy. Let me know if you think there's a fix in Vite that's not too difficult. Another option is we set the above |
Confirmed that it's working now! Thanks a lot @matthewp for the thorough research! vite: {
define: {
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
},
}, |
I was not using vercel adapter but this issue happened to me as well (static) If this is not related to user config, it should be patched in Astro until vite fixes this. While checking the workaround, I have nothing related to node.env in my code, so that’s strange I have to add that code. |
There's two fixes in Vite - vitejs/vite#9791 and vitejs/vite#11151. Both have its own tradeoffs that aren't fully thought out yet, so I don't think it would be fixed soon. I agree that we should keep this as an upstream issue though since there's not much we can do. I don't think the I'll close this one for now. |
What version of
astro
are you using?1.8.0
Are you using an SSR adapter? If so, which one?
Vercel
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
When using a Collection with MDX files, and rendering a page for it as described in the docs, everything works as expected during development.
When I try to build my site however, the build fails.
I get the following error during build:
My astro.config.js:
I didn't add a Stackblitz reproduction, because it happens during build time, and not sure if that would be useful. I linked my Github repo instead, make sure the "use-prerender" branch is selected.
Link to Minimal Reproducible Example
https://github.com/thomasledoux1/website-thomas-astro/tree/feature/use-prerender
Participation
The text was updated successfully, but these errors were encountered: