Skip to content

Commit d20ee94

Browse files
committed
feat: remove MdxRoute and react-router-mdx dependency
- Delete MdxRoute.res and MdxRoute.resi (all pages now handled by split routes) - Remove react-router-mdx from package.json and delete yarn patch - Remove react-router-mdx externals from Mdx.res (loadMdx, loadAllMdx, useMdxComponent, useMdxAttributes, useMdxFiles, allMdx wrapper) - Remove mdxRoutes binding from ReactRouter.res - Remove mdxRoutes variable and spread from routes.res - Remove react-router-mdx init from react-router.config.mjs and generate-route-types.mjs - Migrate BlogRoute to use MdxFile.loadAllAttributes instead of Mdx.allMdx - Migrate SyntaxLookupRoute to use MdxFile.loadAllAttributes instead of loadAllMdx
1 parent 4412018 commit d20ee94

File tree

11 files changed

+3
-327
lines changed

11 files changed

+3
-327
lines changed

.yarn/patches/react-router-mdx-npm-1.0.8-d4402c3003.patch

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

app/routes.res

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,6 @@ let syntaxLookupDetailRoutes =
5959
route(path, "./routes/SyntaxLookupDetailRoute.jsx", ~options={id: path})
6060
)
6161

62-
let mdxRoutes = mdxRoutes("./routes/MdxRoute.jsx")->Array.filter(r =>
63-
!(
64-
r.path
65-
->Option.map(path =>
66-
path === "blog" ||
67-
String.startsWith(path, "blog/") ||
68-
path === "docs/manual" ||
69-
String.startsWith(path, "docs/manual/") ||
70-
path === "docs/react" ||
71-
String.startsWith(path, "docs/react/") ||
72-
path === "docs/guidelines" ||
73-
String.startsWith(path, "docs/guidelines/") ||
74-
path === "community" ||
75-
String.startsWith(path, "community/") ||
76-
path === "syntax-lookup" ||
77-
String.startsWith(path, "syntax-lookup/")
78-
)
79-
->Option.getOr(false)
80-
)
81-
)
82-
8362
let default = [
8463
index("./routes/LandingPageRoute.jsx"),
8564
route("packages", "./routes/PackagesRoute.jsx"),
@@ -101,6 +80,5 @@ let default = [
10180
...docsGuidelinesRoutes,
10281
...communityRoutes,
10382
...syntaxLookupDetailRoutes,
104-
...mdxRoutes,
10583
route("*", "./routes/NotFoundRoute.jsx"),
10684
]

app/routes/BlogRoute.res

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ type loaderData = {posts: array<BlogApi.post>, category: Blog.category}
33
let loader: ReactRouter.Loader.t<loaderData> = async ({request}) => {
44
let showArchived = request.url->String.includes("archived")
55
let posts = async () =>
6-
(await Mdx.allMdx(~filterByPaths=["markdown-pages/blog"]))
7-
->Mdx.filterMdxPages("blog")
6+
(await MdxFile.loadAllAttributes(~dir="markdown-pages/blog"))
87
->Array.map(BlogLoader.transform)
98
->Array.toSorted((a, b) => {
109
a.frontmatter.date->DateStr.toDate > b.frontmatter.date->DateStr.toDate ? -1.0 : 1.0

app/routes/MdxRoute.res

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

app/routes/MdxRoute.resi

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

app/routes/SyntaxLookupRoute.res

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
open ReactRouter
2-
open Mdx
3-
42
type loaderData = {mdxSources: array<SyntaxLookup.item>}
53

64
let convert = (mdx: Mdx.attributes): SyntaxLookup.item => {
@@ -16,14 +14,8 @@ let convert = (mdx: Mdx.attributes): SyntaxLookup.item => {
1614
}
1715

1816
let loader: Loader.t<loaderData> = async _ => {
19-
let allMdx = await Shims.runWithoutLogging(() => loadAllMdx())
20-
2117
let mdxSources =
22-
allMdx
23-
->Array.filter(page =>
24-
page.path->Option.map(String.includes(_, "syntax-lookup"))->Option.getOr(false)
25-
)
26-
->Array.map(convert)
18+
(await MdxFile.loadAllAttributes(~dir="markdown-pages/syntax-lookup"))->Array.map(convert)
2719

2820
{
2921
mdxSources: mdxSources,

generate-route-types.mjs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
import fs from "fs/promises";
2-
import { init } from "react-router-mdx/server";
3-
4-
init({
5-
paths: [
6-
"markdown-pages/blog",
7-
"markdown-pages/docs",
8-
"markdown-pages/community",
9-
"markdown-pages/syntax-lookup",
10-
],
11-
aliases: ["blog", "docs", "community", "syntax-lookup"],
12-
});
132

143
const { default: routes } = await import("./app/routes.mjs");
154

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"react-markdown": "^10.1.0",
7171
"react-router": "^7.12.0",
7272
"react-router-dom": "^7.9.4",
73-
"react-router-mdx": "patch:react-router-mdx@npm%3A1.0.8#~/.yarn/patches/react-router-mdx-npm-1.0.8-d4402c3003.patch",
7473
"rehype-slug": "^6.0.0",
7574
"rehype-stringify": "^10.0.1",
7675
"remark": "^15.0.1",

react-router.config.mjs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
import * as fs from "node:fs";
2-
import { init } from "react-router-mdx/server";
3-
4-
const mdx = init({
5-
paths: [
6-
"markdown-pages/blog",
7-
"markdown-pages/docs",
8-
"markdown-pages/community",
9-
"markdown-pages/syntax-lookup",
10-
],
11-
aliases: ["blog", "docs", "community", "syntax-lookup"],
12-
});
132

143
const { stdlibPaths } = await import("./app/routes.jsx");
154

165
export default {
176
ssr: false,
187

198
async prerender({ getStaticPaths }) {
20-
return [
21-
...(await getStaticPaths()),
22-
...(await mdx.paths()),
23-
...stdlibPaths,
24-
];
9+
return [...(await getStaticPaths()), ...stdlibPaths];
2510
},
2611
buildEnd: async () => {
2712
fs.cpSync("./build/client", "./out", { recursive: true });

0 commit comments

Comments
 (0)