Skip to content

More about markdown support #38

Answered by ElMassimo
Madd0g asked this question in Q&A
Discussion options

You must be logged in to vote

@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 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.

<MyMdxComponent :data="..."/>

If you place it in the components dir, you don't need to import it, it will be automatically resolved.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ElMassimo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants