How to pass props to component embedded in markdown?
See original GitHub issueI have some Vue components inside my nuxt/content markdown:
hello.md:
== Title
<my-component :foo="bar"></my-component>
More text
How do I assign a value to ābarā? Itās straightforward if bar is a constant, and thereās also a method to create a variable in the frontmatter to pass to the component. What I canāt figure out is how to pass in a value from the outer component or page that contains the <nuxt-content>
component.
Hereās what doesnāt work:
- Putting something in data() in the outer component
- Adding a prop to
<nuxt-content>
itself:<nuxt-content :foo="bar">
- Adding a property to the value that gets passed in :document
- Trying to play games in the front matter
I think it might work to use a global variable, this.$foo="bar"
, but that is obviously bad practice.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
How to pass Markdown file as this.props in React?
I see. I'm using gulp, so first I'd need to write a gulp task that takes all the markdown files in the page...
Read more >React Markdown: A Thorough Guide With Markdown Examples
Next, navigate inside the my-markdown-previewer: ... Then pass it as a children prop in the ReactMarkdown component like this:Ā ...
Read more >Props - Nuxt Content
Pass props to your components in Markdown files using the {} MDC syntax.
Read more >Markdown with Custom Components in NextJS | DevLog 007
I used react-markdown to render my markdown files in ReactJS. Each code block in each markdown file is injected into a code editor...
Read more >How to embed React components in markdown using Gatsby ...
MDX is Markdown for the component era. It lets you combine JSX with Markdown's syntax. Yes, you can embed JSX code or even...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ccleve
You can pass props from outside NuxtContent component to components written in markdown files, in the 3rd way you described:
Here is demo in CodeSandbox.
But, if you are talking about Nuxt Content Theme Doc, there is no way you extend
page
object fetched, except patching the package.@NozomuIkuta Amazing š This should be documented on the website.