diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 36c4937..639d915 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,7 +17,18 @@ jobs: - name: Install pnpm run: npm install -g pnpm - run: pnpm install - - run: npm version patch + - name: Commit changes if any + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + if [[ `git status --porcelain` ]]; then + git add . + git commit -m "Auto-commit: Save uncommitted changes before versioning" + fi + + - run: npm version patch -m "Upgrade version to %s [skip ci]" + + - run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/package.json b/package.json index 31ca7ac..39c292f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "shiki-mdx", - "version": "0.0.1", + "name": "@henrmota/shiki-mdx", + "version": "0.0.2", "main": "./dist/index.js", "module": "./dist/index.js", "types": "./dist/index.d.ts", @@ -19,9 +19,12 @@ }, "sideEffects": false, "type": "module", - "keywords": [], - "author": "", - "license": "ISC", + "keywords": [ + "shiki", + "mdx-remote" + ], + "author": "Henrique Mota", + "license": "MIT", "description": "", "devDependencies": { "@types/jest": "^29.5.13", diff --git a/readme.md b/readme.md index e69de29..3be239f 100644 --- a/readme.md +++ b/readme.md @@ -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.