Skip to content

Commit 5e1026f

Browse files
committed
fix: address review issues from PR #1213
- Use String.startsWith instead of String.includes for blog route filtering to avoid accidentally excluding non-blog routes that contain 'blog' as a substring - Replace JsExn.throw with JsError.throwWithMessage in BlogArticleRoute for consistency with BlogApi.res and to get proper Error objects with stack traces - Normalize path separators in MdxFile.scanDir to fix Windows compatibility where Node.Path.join2 produces backslashes
1 parent 8ecfeb8 commit 5e1026f

4 files changed

Lines changed: 8 additions & 4 deletions

File tree

app/routes.res

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

3636
let mdxRoutes =
3737
mdxRoutes("./routes/MdxRoute.jsx")->Array.filter(r =>
38-
!(r.path->Option.map(String.includes(_, "blog"))->Option.getOr(false))
38+
!(r.path->Option.map(String.startsWith(_, "blog"))->Option.getOr(false))
3939
)
4040

4141
let default = [

app/routes/BlogArticleRoute.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let loader: ReactRouter.Loader.t<loaderData> = async ({request}) => {
1515

1616
let frontmatter = switch BlogFrontmatter.decode(frontmatter) {
1717
| Ok(fm) => fm
18-
| Error(msg) => JsExn.throw(msg)
18+
| Error(msg) => JsError.throwWithMessage(msg)
1919
}
2020

2121
let archived = filePath->String.includes("/archived/")

src/MdxFile.res

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ let rec scanDir = (baseDir, currentDir) => {
2828
scanDir(baseDir, fullPath)
2929
} else if Node.Path.extname(entry) === ".mdx" {
3030
// Get the relative path from baseDir
31-
let relativePath = fullPath->String.replace(baseDir ++ "/", "")->String.replace(".mdx", "")
31+
let relativePath =
32+
fullPath
33+
->String.replaceAll("\\", "/")
34+
->String.replace(baseDir->String.replaceAll("\\", "/") ++ "/", "")
35+
->String.replace(".mdx", "")
3236
[relativePath]
3337
} else {
3438
[]

vitest.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export default defineConfig({
1010
setupFiles: ["./vitest.setup.mjs"],
1111
browser: {
1212
enabled: true,
13-
provider: playwright(),
1413
// https://vitest.dev/config/browser/playwright
14+
provider: playwright(),
1515
instances: [
1616
{
1717
browser: "chromium",

0 commit comments

Comments
 (0)