Closed talatkuyuk closed 9 months ago
I've planned to employ @ChristianMurphy's advices later for all of my other plugins.
Weird? The code here generates props
?
It’s also documented: https://mdxjs.com/docs/using-mdx/#props
I see the example that you reference. Interesting...
This issue is related maybe with nextjs
users who are using next-mdx-remote
like me. If so, we can say that this plugin appeals to these users.
Since the next-mdx-remote
is little opinionated to enforce users to pass the props in the scope
like that <MDXRemote scope={{name: "Mars", year: 2022 }} />
, and it's users are able to call the props in the mdx like below:
# Hello {name.toUpperCase()}
The current year is {year}
instead of
# Hello {props.name.toUpperCase()}
The current year is {props.year}
It seems to be next-mdx-remote
, with its scope
.
The tools maintained here put it all in props
.
Hmm. Then, this plugin is valid for only users who are using next-mdx-remote
or other wrappers of the @mdx-js/mdx
that are inline with the the similar implementation, today or in future.
The plugin is added into the docs. Thanks.
Initial checklist
Problem
We are not able to use "props" key in the mdx files like:
Solution
Solution is to change
props
into_props
in the_createMdxContent
function:That is why I created the recma plugin
recma-mdx-change-props
.The
recma-mdx-change-props
changes theprops
parameter into_props
in the function_createMdxContent
; and makes appropriate changes in order to provide us to be able to use for example {props.foo} in the mdx files.I am going to open a PR to add this into the docs. Thanks.
Alternatives
Another alternative would be to make appropriate changes in the
@mdx-js/mdx
package in mayberecma-document.js
. But, I prefer to use therecma-mdx-change-props
in order to make the mdx community accustomed to use recma plugins for who especially needs to use{props.foo}
in the mdx files.