-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d129076
commit 0b80bf5
Showing
4 changed files
with
92 additions
and
44 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,32 @@ | ||
--- | ||
'mdxts': minor | ||
--- | ||
|
||
Adds a `fixImports` prop to `CodeBlock` to allow fixing imports when the source code references files outside the project and can't resolve correctly: | ||
|
||
```tsx | ||
import { CodeBlock } from 'mdxts/components' | ||
|
||
const source = ` | ||
import { Button } from './Button' | ||
export function BasicUsage() { | ||
return <Button>Click Me</Button> | ||
} | ||
` | ||
|
||
export default function Page() { | ||
return <CodeBlock fixImports value={source} /> | ||
} | ||
``` | ||
|
||
An example of this is when rendering a source file that imports a module from a package that is not in the immediate project. The `fixImports` prop will attempt to fix these broken imports using installed packages if a match is found: | ||
|
||
```diff | ||
--import { Button } from './Button' | ||
++import { Button } from 'design-system' | ||
|
||
export function BasicUsage() { | ||
return <Button>Click Me</Button> | ||
} | ||
``` |
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
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