Skip to content

Commit b91fb6f

Browse files
committed
fix breadcrumb links
1 parent 6c27855 commit b91fb6f

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

app/routes/MdxRoute.res

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,21 @@ let default = () => {
305305
<DocsLayout
306306
categories
307307
activeToc={title: "Introduction", entries}
308-
breadcrumbs=?loaderData.breadcrumbs
308+
breadcrumbs=?{loaderData.breadcrumbs->Option.map(crumbs =>
309+
List.mapWithIndex(crumbs, (item, index) => {
310+
if index === 0 {
311+
if (pathname :> string)->String.includes("docs/manual") {
312+
{...item, href: "/docs/manual/introduction"}
313+
} else if (pathname :> string)->String.includes("docs/react") {
314+
{...item, href: "/docs/react/introduction"}
315+
} else {
316+
item
317+
}
318+
} else {
319+
item
320+
}
321+
})
322+
)}
309323
editHref={`https://github.com/rescript-lang/rescript-lang.org/blob/master${loaderData.filePath->Option.getOrThrow}`}
310324
>
311325
<div className="markdown-body"> {component()} </div>

app/routes/NotFoundRoute.res

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
@react.component
22
let default = () => {
3+
let {pathname} = ReactRouter.useLocation()
4+
let navigate = ReactRouter.useNavigate()
5+
6+
React.useEffect(() => {
7+
if (pathname :> string)->String.includes("/react/") {
8+
navigate("/docs/react/introduction")
9+
}
10+
if (pathname :> string)->String.includes("/docs/") {
11+
navigate("/docs/manual/introduction")
12+
}
13+
None
14+
}, [])
15+
316
<div className="pt-36 text-center flex flex-col gap-6 text-gray-80 w-fit mx-auto">
417
<h1 className="hl-title"> {React.string("404")} </h1>
518
<h2 className="text-32"> {React.string("Page Not Found")} </h2>

src/ApiDocs.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ let make = (props: props) => {
377377
let breadcrumbs = ApiLayout.makeBreadcrumbs(~prefix, route)
378378

379379
<SidebarLayout
380-
breadcrumbs={list{{Url.name: "Docs", href: "/docs/manual/introduction"}, ...breadcrumbs}}
380+
breadcrumbs={list{{Url.name: "Docs", href: "/docs/manual/api"}, ...breadcrumbs}}
381381
theme=#Reason
382382
sidebarState=(isSidebarOpen, setSidebarOpen)
383383
sidebar

src/layouts/ApiOverviewLayout.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Docs = {
2424
let {pathname: route} = ReactRouter.useLocation()
2525

2626
let breadcrumbs = list{
27-
{Url.name: "Docs", href: `/docs/manual/introduction`},
27+
{Url.name: "Docs", href: `/docs/manual/api`},
2828
{name: "API", href: `/docs/manual/api`},
2929
}
3030

0 commit comments

Comments
 (0)