Skip to content

Conversation

matthewp
Copy link
Contributor

Description (required)

Documents passing components to MDX <Content /> component.

Related issues & labels (optional)

For withastro/astro#14591

Copy link

netlify bot commented Oct 20, 2025

Deploy Preview for astro-docs-2 ready!

Name Link
🔨 Latest commit 3e9f3b6
🔍 Latest deploy log https://app.netlify.com/projects/astro-docs-2/deploys/68f7e6a777d6ca00088c8200
😎 Deploy Preview https://deploy-preview-12597--astro-docs-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@astrobot-houston
Copy link
Contributor

astrobot-houston commented Oct 20, 2025

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
en/guides/content-collections.mdx Source changed, localizations will be marked as outdated.
en/guides/integrations-guide/mdx.mdx Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do already document this here: https://docs.astro.build/en/guides/integrations-guide/mdx/#custom-components-with-imported-mdx

Maybe we can link there? Or tweak it if we need to clarify anything?

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @matthewp , this is a helpful example! See my comments below, including a question making sure it's clear how including the default exports work!

@sarah11918 sarah11918 added add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!) labels Oct 21, 2025
@sarah11918
Copy link
Member

Following up, now Chris's comment is appearing for me. I'm going to suggest we keep this content in the MDX page only and perhaps link to it from the content collections page.

Maybe it's the MDX page that needs beefing up so it's obvious that this works in content collections, too!

@sarah11918
Copy link
Member

OK! So I updated both the text on the content collections and the MDX pages so that the main content is all on the MDX page and content collections links to it.

I made this intentionally as big as it could be, showing both a plain "import from MDX" and a content collections example. Would love help fixing up the MDX stuff to make sure it's helpful enough for both scenarios, but not too much! @delucis

@sarah11918
Copy link
Member

(Noting two link issues we can address once we've decided on a section heading)

Copy link
Member

@ArmandPhilippot ArmandPhilippot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! I left a comment for the heading and another nit because I think "blog posts" might confuse some people?

<ReactCounter client:load />
```

#### Custom components with imported MDX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Custom components with MDX" instead. I think "imported" might confuse people because when they use content collections, they are not importing the files themselves.

Otherwise, to fix the link directly, "Passing components to MDX content" sounds fine to me!

Copy link
Member

@sarah11918 sarah11918 Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think this is the perfect heading as-is yet, so def want us to workshop this (especially as we know it will cause link chaos when we change it!)

I worry that "Custom components with MDX" is a little too generic? Like maybe this could be importing your UI components into MDX?

"Passing components to MDX content" was the best thought I had so far, and nothing else on this page is very API-forward e.g. "Using the components prop" so it probably should stay very use-case based.

Even still, the "passing" emphasizes the implementation, not the end goal. It's really more like "Assigning custom elements to HTML elements... when using the <Content /> component to pull in and render your Markdown. Maybe this should in fact be a sub-section of THAT section?

UPDATE: reorganized (but did not change section heading as it's not quite as bad in this flow now?) Can still debate whether it needs changing!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I understand what you mean. I agree "Custom components with MDX" might be confusing!

I haven't had a chance to see the live preview yet 😅 , but looking at the "code" changes, the reorganization looks better. I'm still a bit concern regarding this heading. We precise this include content collections but maybe someone scanning the page would miss that seeing "imported"?

What I can think of "Overwrite HTML elements with custom components" or "Customizing HTML elements with MDX" but... this sounds a bit duplicated with the previous section. Maybe "Using custom components from your Astro components"? I can't find something better, so maybe what we have currently is fine!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like "Passing components to MDX content" of the options discussed, but will leave it up to you.

Copy link
Member

@ArmandPhilippot ArmandPhilippot Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, now the note has moved I think "Passing" makes sense here. I don't know if that's the right word (I mean balanced, "passing" seems fine!), but it seems more balanced to me: Assigning/Passing. And because this reused the same wording as the note it shouldn't confuse users.

sarah11918 and others added 2 commits October 21, 2025 10:31
@sarah11918
Copy link
Member

OK, I addressed Yan's grammar nits, and @ArmandPhilippot , what do you think of this new order/flow? I honestly think this whole thing feels much better in this order!

@sarah11918
Copy link
Member

Updating branch to hopefully get a deploy preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add new content Document something that is not in docs. May require testing, confirmation, or affect other pages. merge-on-release Don't merge this before the feature is released! (MQ=approved but WAIT for feature release!)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants