-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
3 changed files
with
77 additions
and
6 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
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,57 @@ | ||
# @henmota/shiki-mdx | ||
|
||
A plugin for MDX that utilizes Shiki for syntax highlighting. This package is designed to be used in conjunction with Next.js and the `remote-mdx` library. | ||
|
||
## Installation | ||
|
||
To install the package, you can use npm or yarn. Make sure to also install Shiki as a peer dependency. | ||
|
||
```bash | ||
npm install @henmota/shiki-mdx shiki | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import { compileMDX } from "remote-mdx"; | ||
import { remarkShikiMdx } from "@henmota/shiki-mdx"; | ||
import remarkMath from "remark-math"; | ||
import remarkGfm from "remark-gfm"; | ||
import rehypeKatex from "rehype-katex"; | ||
import rehypeRaw from "rehype-raw"; | ||
|
||
const content = ` | ||
# Your MDX Content Here | ||
\`\`\`js | ||
console.log('Hello, world!'); | ||
\`\`\` | ||
`; | ||
|
||
const components = {}; // Your custom components | ||
|
||
const { frontmatter, mdxContent } = await compileMDX({ | ||
source: content, | ||
components: { ...defaultComponents, ...components }, | ||
options: { | ||
mdxOptions: { | ||
remarkPlugins: [ | ||
remarkMath, | ||
remarkGfm, | ||
[remarkShikiMdx, { theme: "vitesse-dark" }], | ||
], | ||
rehypePlugins: [rehypeKatex, rehypeRaw], | ||
format: "mdx", | ||
}, | ||
parseFrontmatter: true, | ||
}, | ||
}); | ||
``` | ||
|
||
## Peer Dependencies | ||
|
||
This package requires shiki as a peer dependency. Ensure that it is installed in your project. | ||
|
||
## Supported Themes | ||
|
||
Shiki supports a variety of themes. For a full list of available themes, check the Shiki documentation. |