@@ -3,24 +3,16 @@ import webpack from "webpack";
3
3
import rehypeSlug from 'rehype-slug' ;
4
4
import remarkGfm from 'remark-gfm' ;
5
5
import remarkComment from 'remark-comment' ;
6
- import nextMDX from "@next/mdx" ;
7
6
import remarkFrontmatter from 'remark-frontmatter'
7
+ import remarkMdxFrontmatter from "remark-mdx-frontmatter" ;
8
+ import { createLoader } from 'simple-functional-loader'
8
9
9
10
const bsconfig = JSON . parse ( fs . readFileSync ( "./bsconfig.json" ) )
10
11
11
12
const { ProvidePlugin } = webpack ;
12
13
13
14
const transpileModules = [ "rescript" ] . concat ( bsconfig [ "bs-dependencies" ] ) ;
14
15
15
- const withMDX = nextMDX ( {
16
- extension : / \. m d x ? $ / ,
17
- options : {
18
- remarkPlugins : [ remarkComment , remarkGfm , remarkFrontmatter ] ,
19
- providerImportSource : '@mdx-js/react' ,
20
- rehypePlugins : [ rehypeSlug ]
21
- } ,
22
- } ) ;
23
-
24
16
const config = {
25
17
pageExtensions : [ "jsx" , "js" , "bs.js" , "mdx" , "mjs" ] ,
26
18
env : {
@@ -50,6 +42,37 @@ const config = {
50
42
fullySpecified : false ,
51
43
} ,
52
44
} ) ;
45
+
46
+ function mainMdxLoader ( plugins ) {
47
+ return [
48
+ createLoader ( function ( source ) {
49
+ const result = `${ source } \n\nMDXContent.frontmatter = frontmatter`
50
+ return result
51
+ } ) ,
52
+ ]
53
+ }
54
+
55
+ config . module . rules . push ( {
56
+ test : / \. m d x ? $ / ,
57
+ use : mainMdxLoader ( ) ,
58
+ } ) ;
59
+
60
+ config . module . rules . push ( {
61
+ test : / \. m d x ? $ / ,
62
+ use : [
63
+ {
64
+ loader : '@mdx-js/loader' ,
65
+ /** @type {import('@mdx-js/loader').Options } */
66
+ options : {
67
+ remarkPlugins : [ remarkComment , remarkGfm , remarkFrontmatter , remarkMdxFrontmatter ] ,
68
+ providerImportSource : '@mdx-js/react' ,
69
+ rehypePlugins : [ rehypeSlug ]
70
+ }
71
+ }
72
+ ]
73
+ } ) ;
74
+
75
+
53
76
config . plugins . push ( new ProvidePlugin ( { React : "react" } ) ) ;
54
77
return config ;
55
78
} ,
@@ -69,7 +92,7 @@ const config = {
69
92
} ,
70
93
} ;
71
94
72
- export default withMDX ( {
95
+ export default {
73
96
transpilePackages : transpileModules ,
74
97
...config
75
- } )
98
+ }
0 commit comments