Skip to content

Commit f571352

Browse files
committed
configure loadmdx
1 parent d167bf2 commit f571352

File tree

4 files changed

+58
-169
lines changed

4 files changed

+58
-169
lines changed

app/routes/MdxRoute.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ let apiTableOfContents = () => {
122122
let loader: Loader.t<loaderData> = async ({request}) => {
123123
let {pathname} = WebAPI.URL.make(~url=request.url)
124124
Console.log(pathname)
125-
let mdx = await loadMdx(request)
125+
let mdx = await loadMdx(request, ~options={remarkPlugins: [Mdx.gfm]})
126126

127127
// TODO: actually render the blog pages
128128
if pathname->String.includes("blog") {

package-lock.json

Lines changed: 46 additions & 166 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
"highlightjs-rescript": "^0.2.2",
4545
"isbot": "^5",
4646
"lz-string": "^1.4.4",
47+
"mdast-util-from-markdown": "^2.0.2",
48+
"mdast-util-toc": "^7.1.0",
4749
"react": "^19.1.0",
4850
"react-dom": "^19.1.0",
4951
"react-markdown": "^10.1.0",
@@ -76,4 +78,4 @@
7678
"tailwindcss": "^4",
7779
"vite": "^7.0.6"
7880
}
79-
}
81+
}

src/bindings/ReactRouter.res

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,12 @@ module Mdx = {
109109
@module("react-router-mdx/server")
110110
external routes: string => array<Routes.t> = "routes"
111111

112+
type remarkPlugin
113+
114+
type loadMdxOptions = {remarkPlugins?: array<remarkPlugin>}
115+
112116
@module("react-router-mdx/server")
113-
external loadMdx: FetchAPI.request => promise<t> = "loadMdx"
117+
external loadMdx: (FetchAPI.request, ~options: loadMdxOptions=?) => promise<t> = "loadMdx"
114118

115119
@module("react-router-mdx/client")
116120
external useMdxAttributes: unit => attributes = "useMdxAttributes"
@@ -124,4 +128,7 @@ module Mdx = {
124128

125129
@module("react-router-mdx/client")
126130
external useMdxFiles: unit => {..} = "useMdxFiles"
131+
132+
@module("remark-gfm")
133+
external gfm: remarkPlugin = "default"
127134
}

0 commit comments

Comments
 (0)