Skip to content

Commit 1e76030

Browse files
Address comments + remove Prism.css since it's now unnecessary
1 parent a79cdee commit 1e76030

File tree

9 files changed

+20
-414
lines changed

9 files changed

+20
-414
lines changed

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: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
77
"sideEffects": false,
8-
"files": [
9-
"dist"
10-
],
8+
"files": ["dist"],
119
"exports": {
1210
".": {
1311
"import": "./dist/index.js",
@@ -29,15 +27,14 @@
2927
},
3028
"scripts": {
3129
"prepare": "npm run build",
32-
"build": "tsc --project tsconfig.build.json && yarn copy:css",
30+
"build": "tsc --project tsconfig.build.json",
3331
"clean:build": "rimraf dist",
3432
"clean:all": "rimraf node_modules .eslintcache && yarn clean:build",
3533
"watch": "tsc --watch",
3634
"type": "tsc --noEmit",
3735
"lint": "eslint . --cache",
3836
"format": "prettier . --write",
39-
"format:check": "prettier . --check",
40-
"copy:css": "cp -r ./src/styles/prism.css ./dist/styles.css"
37+
"format:check": "prettier . --check"
4138
},
4239
"author": "Mintlify, Inc.",
4340
"license": "MIT",

packages/mdx/src/plugins/rehype/rehypeSyntaxHighlighting.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
DEFAULT_LANG_ALIASES,
99
SHIKI_THEMES,
1010
UNIQUE_LANGS,
11+
DEFAULT_LANG,
1112
type ShikiLang,
1213
type ShikiTheme,
1314
} from './shiki-constants.js';
@@ -92,15 +93,15 @@ export const rehypeSyntaxHighlighting: Plugin<[RehypeSyntaxHighlightingOptions?]
9293
let lang =
9394
getLanguage(node, DEFAULT_LANG_ALIASES) ??
9495
getLanguage(child, DEFAULT_LANG_ALIASES) ??
95-
'text';
96+
DEFAULT_LANG;
9697

9798
try {
9899
const code = toString(node);
99100
const lines = code.split('\n');
100101
let linesToHighlight = getLinesToHighlight(node, lines.length);
101102

102103
const hast = highlighter.codeToHast(code, {
103-
lang: lang ?? 'text',
104+
lang: lang ?? DEFAULT_LANG,
104105
themes: {
105106
light:
106107
options.themes?.light ??

packages/mdx/src/plugins/rehype/shiki-constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { BundledLanguage } from 'shiki';
22

33
export type ShikiLang = BundledLanguage | 'text';
44

5+
export const DEFAULT_LANG = 'text' as const;
6+
57
export const DEFAULT_LANG_ALIASES: Record<string, ShikiLang> = {
68
abap: 'abap',
79
'actionscript-3': 'actionscript-3',

0 commit comments

Comments
 (0)