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

Add minimal support for the components prop #396

Merged
merged 1 commit into from
Feb 12, 2024
Merged

Conversation

remcohaszing
Copy link
Member

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

This defines the _components variable in _createMdxContent. This variable contains all components injected through the components prop, a reference to props, and all local variables. All MDX JSX tags are prefixed with _components. in the virtual code.

As a result, components declared in the components prop are allowed. Components from both the components prop and local variables are displayed in the autocomplete.

A downside of this approach is that documentation is lost for local components. To mitigate this, only unknown JSX tags are prefixed.

Only MDX JSX tags are handled yet. JSX from estree not yet.

Refs #260

This defines the `_components` variable in `_createMdxContent`. This
variable contains all components injected through the `components` prop,
a reference to `props`, and all local variables. All MDX JSX tags are
prefixed with `_components.` in the virtual code.

As a result, components declared in the `components` prop are allowed.
Components from both the `components` prop and local variables are
displayed in the autocomplete.

A downside of this approach is that documentation is lost for local
components. To mitigate this, only unknown JSX tags are prefixed.

Only MDX JSX tags are handled yet. JSX from estree not yet.

Refs #260
@remcohaszing remcohaszing added 🦋 type/enhancement This is great to have 🗄 area/interface This affects the public interface 👶 semver/patch This is a backwards-compatible fix 👍 phase/yes Post is accepted and can be worked on labels Feb 12, 2024
Copy link

changeset-bot bot commented Feb 12, 2024

🦋 Changeset detected

Latest commit: e2eea02

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@mdx-js/language-service Patch
@mdx-js/language-server Patch
vscode-mdx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This comment has been minimized.

@remcohaszing remcohaszing merged commit 3b6c5a8 into main Feb 12, 2024
13 checks passed
@remcohaszing remcohaszing deleted the components branch February 12, 2024 15:44
@remcohaszing remcohaszing added the 💪 phase/solved Post is done label Feb 12, 2024

This comment has been minimized.

@github-actions github-actions bot removed the 👍 phase/yes Post is accepted and can be worked on label Feb 12, 2024
@github-actions github-actions bot mentioned this pull request Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 👶 semver/patch This is a backwards-compatible fix 🦋 type/enhancement This is great to have
Development

Successfully merging this pull request may close these issues.

None yet

1 participant