-
What happens to a markdown after all the markdown plugins transformed it? It looks like it turns into a bunch of JSX functions and then it gets wrapped as a vue component? I'm wondering if it's possible to write a plugin that enhances this generated vue component? For example I want to fetch some data and make it available in the markdown - is there a hook or something to allow a plugin to do that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@Madd0g MDX components can receive props. Although you could enhance it in other ways, mixing too much code in MDX makes it harder to read. If using MDX pages, the outer component could be a layout, that fetches the necessary data, and uses a dynamic binding in the default slot: <slot :data="..."/> Which can then be accessed in MDX as Alternatively a more flexible approach is to create a Vue page, fetch the data in <MyMdxComponent :data="..."/> If you place it in the components dir, you don't need to import it, it will be automatically resolved. |
Beta Was this translation helpful? Give feedback.
@Madd0g MDX components can receive props. Although you could enhance it in other ways, mixing too much code in MDX makes it harder to read.
If using MDX pages, the outer component could be a layout, that fetches the necessary data, and uses a dynamic binding in the default slot:
Which can then be accessed in MDX as
props.data
.Alternatively a more flexible approach is to create a Vue page, fetch the data in
script setup
and then pass it as props to an imported MDX component.If you place it in the components dir, you don't need to import it, it will be automatically resolved.