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

Share custom components in nested MDX files #227

Merged
merged 4 commits into from
Mar 28, 2024

Conversation

ProchaLu
Copy link
Contributor

Closes #195

What:

This pull request adds a Readme guide to make sure custom components are accessible in nested MDX files.

Why:

With the current behaviour, passing custom components to nested MDX files is leading to unexpected rendering issues. This solution and Readme guide allows to share custom components across the MDX structure.

How:

  • Adding a new section to the README.md file providing a step-by-step solution
  • The solution uses MDXProvider from @mdx-js/react

Checklist:

  • Documentation
  • Tests N/A
  • Ready to be merged

@ProchaLu
Copy link
Contributor Author

Hi @kentcdodds, can you check out the PR when you have a moment. Your feedback would be great and maybe the PR will be merged. Thanks!

Copy link
Owner

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Handy! This is not a very common usecase though so I would prefer to put it just before the Known Issues section.

@karlhorky
Copy link
Contributor

karlhorky commented Mar 27, 2024

This is not a very common usecase though

@kentcdodds Just ran across this - do you think it's not common? My gut feel says that it would be the most common use case.

Currently when you have the following simple setup, it breaks:

1.mdx

import Partial from './2.mdx'

<Partial />

2.mdx

# Partial content

Some content that is shared across multiple pages

<SomeComponentFromProvider /> {/* 💥 */}

@kentcdodds
Copy link
Owner

🤷‍♂️ I'd still like the docs for this moved down.

@ProchaLu
Copy link
Contributor Author

@kentcdodds , thanks for the review! I changed the position and moved it before the "Known Issues" section

Copy link
Owner

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Stellar. Thanks!

@kentcdodds kentcdodds merged commit 073d910 into kentcdodds:main Mar 28, 2024
@ProchaLu ProchaLu deleted the update-readme-nested-files branch March 28, 2024 11:38
Copy link

🎉 This PR is included in version 10.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggestion: Example for MDXProvider with mdx-bundler for component substitution
3 participants