Skip to content
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

Incomplete or unclear guide for custom MDX components #7208

Open
aureliendossantos opened this issue Mar 6, 2024 · 0 comments
Open

Incomplete or unclear guide for custom MDX components #7208

aureliendossantos opened this issue Mar 6, 2024 · 0 comments
Labels
improve documentation Enhance existing documentation (e.g. add an example, improve description)

Comments

@aureliendossantos
Copy link
Contributor

📚 Subject area/topic

MDX custom components

📋 Page(s) affected (or suggested, for new content)

https://docs.astro.build/en/guides/markdown-content/

📋 Description of content that is out-of-date or incorrect

I’ve been trying to figure out how to use custom MDX components, and I think a few points in the docs need clarification, especially as a user of content collections:

  1. There is a simple example of how to make a custom > blockquote using <slot />. However, neither the Astro docs nor the linked MDX page explain how to write the custom component for a more complex syntax like [title](http://link).

  2. This example seems useful if you directly import a .mdx file, but is confusing if you use a content collection, because the components variable doesn’t exist, so you don’t know if you still have to import and pass back your custom components, as said in the “Note”.

  3. The same example shows that you can replace a set of keywords h1, a, etc. with a custom component. However, it wasn’t clear to me that you can simply pass a component like this: <Content components={{ MyComponent }} />. I just randomly tried it and it worked. I think it should be more clear because it’s precisely what I was looking for: I didn't need to replace a keyword like h1, but my own custom component depending on the page rendering the <Content />, ie by doing <Content components={{ MyComponent: AlternativeComponent }} />.

I hope this feedback can be useful!

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

No response

@aureliendossantos aureliendossantos added the improve documentation Enhance existing documentation (e.g. add an example, improve description) label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve documentation Enhance existing documentation (e.g. add an example, improve description)
Projects
None yet
Development

No branches or pull requests

1 participant