Skip to content

Commit 05d5b5d

Browse files
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5208edb commit 05d5b5d

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

app/routes.res

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ let blogArticleRoutes =
3535

3636
let mdxRoutes =
3737
mdxRoutes("./routes/MdxRoute.jsx")->Array.filter(r =>
38-
!(r.path->Option.map(String.startsWith(_, "blog"))->Option.getOr(false))
38+
!(r.path
39+
->Option.map(path => path === "blog" || String.startsWith(path, "blog/"))
40+
->Option.getOr(false)
41+
)
3942
)
4043

4144
let default = [

src/MdxFile.res

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ let resolveFilePath = (pathname, ~dir, ~alias) => {
3030
} else {
3131
pathname
3232
}
33-
let relativePath = path->String.replace(alias, dir)
33+
let relativePath =
34+
if path->String.startsWith(alias ++ "/") {
35+
let rest = path->String.slice(~start=String.length(alias) + 1, ~end=String.length(path))
36+
Node.Path.join2(dir, rest)
37+
} else if path->String.startsWith(alias) {
38+
let rest = path->String.slice(~start=String.length(alias), ~end=String.length(path))
39+
Node.Path.join2(dir, rest)
40+
} else {
41+
path
42+
}
3443
relativePath ++ ".mdx"
3544
}
3645

0 commit comments

Comments
 (0)