-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support custom components provided via a provider (#402)
This adds support for components provided via the `providerImportSource` option. The user can specify which components are available by specifying the `MDXProvidedComponents` type either locally inside the MDX file or for all MDX files by declaring it globally. Closes #399
- Loading branch information
1 parent
48be843
commit cd59565
Showing
9 changed files
with
166 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@mdx-js/language-service": patch | ||
"@mdx-js/language-server": patch | ||
"vscode-mdx": patch | ||
--- | ||
|
||
Support custom components provided via a provider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {type ReactNode} from 'react' | ||
|
||
export type PlanetProps = { | ||
distanceFromStar: number | ||
|
||
name: string | ||
|
||
radius: number | ||
} | ||
|
||
/** | ||
* A planet in a solar system. | ||
*/ | ||
export function Planet({ | ||
distanceFromStar, | ||
name, | ||
radius | ||
}: PlanetProps): ReactNode { | ||
return ( | ||
<section> | ||
<dl> | ||
<dd>Name</dd> | ||
<dt>{name}</dt> | ||
<dd>Radius</dd> | ||
<dt>{radius}</dt> | ||
<dd>Distance from star</dd> | ||
<dt>{distanceFromStar}</dt> | ||
</dl> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Solar system | ||
|
||
<Planet name="Earth" radius={6371} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"module": "node16", | ||
"strict": true | ||
}, | ||
"mdx": { | ||
"checkMdx": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {type Planet} from './components.js' | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
type MDXProvidedComponents = { | ||
Planet: typeof Planet | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.