File tree Expand file tree Collapse file tree 9 files changed +20
-414
lines changed Expand file tree Collapse file tree 9 files changed +20
-414
lines changed Original file line number Diff line number Diff line change 1
- import '@mintlify/mdx/dist/styles.css' ;
2
1
import type { Metadata } from 'next' ;
3
2
4
3
import '@/app/globals.css' ;
Original file line number Diff line number Diff line change @@ -30,23 +30,3 @@ You can check out the demo of [this page](https://github.com/mintlify/mdx/blob/m
30
30
);
31
31
}
32
32
```
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
- ```
Original file line number Diff line number Diff line change 1
- import '@mintlify/mdx/dist/styles.css' ;
2
1
import { AppProps } from 'next/app' ;
3
2
4
3
import '@/styles/globals.css' ;
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ You can check out the demo of [this page](https://github.com/mintlify/mdx/blob/m
19
19
});
20
20
21
21
if (' error' in mdxSource ) {
22
- // handle error case
22
+ // handle error case
23
23
}
24
24
25
25
return { props: { mdxSource } };
@@ -35,14 +35,3 @@ You can check out the demo of [this page](https://github.com/mintlify/mdx/blob/m
35
35
return <MDXClient { ... mdxSource } />;
36
36
}
37
37
```
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
- ```
Original file line number Diff line number Diff line change 5
5
"main" : " ./dist/index.js" ,
6
6
"types" : " ./dist/index.d.ts" ,
7
7
"sideEffects" : false ,
8
- "files" : [
9
- " dist"
10
- ],
8
+ "files" : [" dist" ],
11
9
"exports" : {
12
10
"." : {
13
11
"import" : " ./dist/index.js" ,
29
27
},
30
28
"scripts" : {
31
29
"prepare" : " npm run build" ,
32
- "build" : " tsc --project tsconfig.build.json && yarn copy:css " ,
30
+ "build" : " tsc --project tsconfig.build.json" ,
33
31
"clean:build" : " rimraf dist" ,
34
32
"clean:all" : " rimraf node_modules .eslintcache && yarn clean:build" ,
35
33
"watch" : " tsc --watch" ,
36
34
"type" : " tsc --noEmit" ,
37
35
"lint" : " eslint . --cache" ,
38
36
"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"
41
38
},
42
39
"author" : " Mintlify, Inc." ,
43
40
"license" : " MIT" ,
Original file line number Diff line number Diff line change 8
8
DEFAULT_LANG_ALIASES ,
9
9
SHIKI_THEMES ,
10
10
UNIQUE_LANGS ,
11
+ DEFAULT_LANG ,
11
12
type ShikiLang ,
12
13
type ShikiTheme ,
13
14
} from './shiki-constants.js' ;
@@ -92,15 +93,15 @@ export const rehypeSyntaxHighlighting: Plugin<[RehypeSyntaxHighlightingOptions?]
92
93
let lang =
93
94
getLanguage ( node , DEFAULT_LANG_ALIASES ) ??
94
95
getLanguage ( child , DEFAULT_LANG_ALIASES ) ??
95
- 'text' ;
96
+ DEFAULT_LANG ;
96
97
97
98
try {
98
99
const code = toString ( node ) ;
99
100
const lines = code . split ( '\n' ) ;
100
101
let linesToHighlight = getLinesToHighlight ( node , lines . length ) ;
101
102
102
103
const hast = highlighter . codeToHast ( code , {
103
- lang : lang ?? 'text' ,
104
+ lang : lang ?? DEFAULT_LANG ,
104
105
themes : {
105
106
light :
106
107
options . themes ?. light ??
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import type { BundledLanguage } from 'shiki';
2
2
3
3
export type ShikiLang = BundledLanguage | 'text' ;
4
4
5
+ export const DEFAULT_LANG = 'text' as const ;
6
+
5
7
export const DEFAULT_LANG_ALIASES : Record < string , ShikiLang > = {
6
8
abap : 'abap' ,
7
9
'actionscript-3' : 'actionscript-3' ,
You can’t perform that action at this time.
0 commit comments