-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[gatsby-plugin-mdx] CMS Live Preview #16357
Comments
I don't think this is related to the Gatsby project. There is an open discussion at Netlify CMS repository though. The live preview is rather complicated because it's not a live preview - you precompile the component and load it in as the Netlify CMS widget. That's why the MDX widget has rather strict import setup configuration. If you have any issues/questions regards the preview widget I suggest opening an issue the widget repository and I'll see what I can help you with 😉 |
@buz-zard I do agree to an extent, and did consider raising the issue there, but considering how many people are now jumping onto MDX (paticularly through I'd definitely take up your support in the meantime though, thanks! |
True, with more discussions a solution could occur. There is also an issue in mdx monorepo on improving the mdx runtime, as from version 1.0.0 the mdx runtime doesn't even work with |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing! Thanks for being a part of the Gatsby community! 💪💜 |
Please keep open 😢 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing! Thanks again for being part of the Gatsby community! |
Description
Templates that use
gatsby-plugin-mdx
'sMDXRenderer
don't render as expected in a CMS "live-preview" environmentIn other words, if I make a change to content, I would expect this to re-render the MDX as a live preview.
Additional context
I also raised this with @ChristopherBiscardi via Twitter DM and he suggested the following:
Steps to reproduce
Currently using
gatsby-plugin-mdx
in my personal site, withnetlify-cms
:https://github.com/joe-bell/joebell.co.uk
The content converts to HTML (and previews the plain HTML, no CSS or MDX transformed markup) just fine using the
"markdown"
widget.I investigated this further in a separate branch
fix/preview
(which is super unstable and prone to changes) and managed to get the template component mapped to the CMS preview but it failed to render the content (which is rendered viaMDXRenderer
, I've temporarily removed this in the branch to experiment).Expected result
I think there's two things needed for this to work (but as more of a UI-focussed dev I may need some support to get this "concept" working).
Adjustments to
MDXRenderer
to support run-time environment.If I use the
MDXRenderer
in a template component, it should just render the content as expected. The sameMDXProvider
could be imported in the CMS config to keep config aligned (e.g. components/scope).Perhaps even
wrapRootElement
could be used instead, keeping all wrapper components (MDXProvider/ThemeProvider/styles in line with the app). (this probably leaks into the scope ofgatsby-plugin-netlify-cms
An CMS-agnostic "widget" that can be used to render the above
e.g. in
netlify-cms
'sconfig.yml
, something like:widget: "mdx"
I have tried
netlify-cms-widget-mdx
but struggled to get it set-up, personally I'd prefer an approach similar to above that keeps additional configuration to the MDXRenderer to a minimum (perhaps @buz-zard could offer some words of wisdom here).Actual result
"White screen" / the content fails to render.
Environment
The text was updated successfully, but these errors were encountered: