Skip to content

Commit 86958ae

Browse files
Replace Refractor/Prism with Shiki
2 parents abc7e11 + 8aa5e85 commit 86958ae

File tree

15 files changed

+928
-650
lines changed

15 files changed

+928
-650
lines changed

.yarn/install-state.gz

12.1 KB
Binary file not shown.

examples/app-router/app/layout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import '@mintlify/mdx/dist/styles.css';
21
import type { Metadata } from 'next';
32

43
import '@/app/globals.css';

examples/app-router/readme.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,3 @@ You can check out the demo of [this page](https://github.com/mintlify/mdx/blob/m
3030
);
3131
}
3232
```
33-
34-
2. Import `@mintlify/mdx/dist/styles.css` inside your `layout.tsx` file. This file contains the styles for the code syntax highlighting.
35-
36-
```tsx
37-
import '@mintlify/mdx/dist/styles.css';
38-
import type { Metadata } from 'next';
39-
40-
export const metadata: Metadata = {
41-
title: 'Create Next App',
42-
description: 'Generated by create next app',
43-
};
44-
45-
export default function RootLayout({ children }: { children: React.ReactNode }) {
46-
return (
47-
<html lang="en">
48-
<body>{children}</body>
49-
</html>
50-
);
51-
}
52-
```

examples/pages-router/pages/_app.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import '@mintlify/mdx/dist/styles.css';
21
import { AppProps } from 'next/app';
32

43
import '@/styles/globals.css';

examples/pages-router/readme.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ You can check out the demo of [this page](https://github.com/mintlify/mdx/blob/m
1919
});
2020

2121
if ('error' in mdxSource) {
22-
// handle error case
22+
// handle error case
2323
}
2424

2525
return { props: { mdxSource } };
@@ -35,14 +35,3 @@ You can check out the demo of [this page](https://github.com/mintlify/mdx/blob/m
3535
return <MDXClient {...mdxSource} />;
3636
}
3737
```
38-
39-
3. Import `@mintlify/mdx/dist/styles.css` inside your `_app.tsx` file. This file contains the styles for the code syntax highlighting.
40-
41-
```tsx
42-
import '@mintlify/mdx/dist/styles.css';
43-
import { AppProps } from 'next/app';
44-
45-
export default function App({ Component, pageProps }: AppProps) {
46-
return <Component {...pageProps} />;
47-
}
48-
```

packages/mdx/package.json

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
{
22
"name": "@mintlify/mdx",
3-
"version": "1.0.2",
3+
"version": "2.0.0",
44
"description": "Markdown parser from Mintlify",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
77
"sideEffects": false,
88
"files": [
99
"dist"
1010
],
11+
"exports": {
12+
".": {
13+
"import": "./dist/index.js",
14+
"types": "./dist/index.d.ts"
15+
},
16+
"./plugins": {
17+
"import": "./dist/plugins/index.js",
18+
"types": "./dist/plugins/index.d.ts"
19+
}
20+
},
1121
"type": "module",
1222
"publishConfig": {
1323
"access": "public",
@@ -19,15 +29,14 @@
1929
},
2030
"scripts": {
2131
"prepare": "npm run build",
22-
"build": "tsc --project tsconfig.build.json && yarn copy:css",
32+
"build": "tsc --project tsconfig.build.json",
2333
"clean:build": "rimraf dist",
2434
"clean:all": "rimraf node_modules .eslintcache && yarn clean:build",
2535
"watch": "tsc --watch",
2636
"type": "tsc --noEmit",
2737
"lint": "eslint . --cache",
2838
"format": "prettier . --write",
29-
"format:check": "prettier . --check",
30-
"copy:css": "cp -r ./src/styles/prism.css ./dist/styles.css"
39+
"format:check": "prettier . --check"
3140
},
3241
"author": "Mintlify, Inc.",
3342
"license": "MIT",
@@ -38,8 +47,10 @@
3847
"@mintlify/ts-config": "^2.0.2",
3948
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
4049
"@tsconfig/recommended": "1.x",
50+
"@types/hast": "^3.0.4",
4151
"@types/react": "^18.3.11",
4252
"@types/react-dom": "^18.3.0",
53+
"@types/unist": "^3.0.3",
4354
"@typescript-eslint/eslint-plugin": "6.x",
4455
"@typescript-eslint/parser": "6.x",
4556
"eslint": "8.x",
@@ -57,15 +68,14 @@
5768
"react-dom": "^18.3.1"
5869
},
5970
"dependencies": {
60-
"@types/hast": "^3.0.4",
61-
"@types/unist": "^3.0.3",
6271
"hast-util-to-string": "^3.0.1",
72+
"mdast-util-mdx-jsx": "^3.2.0",
6373
"next-mdx-remote-client": "^1.0.3",
64-
"refractor": "^4.8.1",
6574
"rehype-katex": "^7.0.1",
6675
"remark-gfm": "^4.0.0",
6776
"remark-math": "^6.0.0",
6877
"remark-smartypants": "^3.0.2",
78+
"shiki": "^3.6.0",
6979
"unified": "^11.0.0",
7080
"unist-util-visit": "^5.0.0"
7181
}

packages/mdx/src/client/rsc.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ import remarkGfm from 'remark-gfm';
55
import remarkMath from 'remark-math';
66
import remarkSmartypants from 'remark-smartypants';
77

8-
import { rehypeSyntaxHighlighting } from '../plugins/index.js';
8+
import { rehypeSyntaxHighlighting, RehypeSyntaxHighlightingOptions } from '../plugins/index.js';
99

1010
export async function MDXRemote({
1111
source,
1212
mdxOptions,
1313
scope,
1414
components,
1515
parseFrontmatter,
16+
syntaxHighlightingOptions,
1617
}: {
1718
source: string;
1819
mdxOptions?: SerializeOptions['mdxOptions'];
1920
scope?: SerializeOptions['scope'];
2021
components?: MDXComponents;
2122
parseFrontmatter?: SerializeOptions['parseFrontmatter'];
23+
syntaxHighlightingOptions?: RehypeSyntaxHighlightingOptions;
2224
}) {
2325
return (
2426
// @ts-expect-error Server Component
@@ -36,7 +38,7 @@ export async function MDXRemote({
3638
],
3739
rehypePlugins: [
3840
rehypeKatex,
39-
[rehypeSyntaxHighlighting, { ignoreMissing: true }],
41+
[rehypeSyntaxHighlighting, syntaxHighlightingOptions],
4042
...(mdxOptions?.rehypePlugins || []),
4143
],
4244
format: mdxOptions?.format || 'mdx',

packages/mdx/src/lib/syntaxHighlighting/blade.js

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)