Skip to content

Commit d9e2c8c

Browse files
committed
update links back to current docs
1 parent ae66698 commit d9e2c8c

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/SyntaxLookup.res

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,14 @@ let default = (props: props) => {
352352
<div className="mb-8 text-gray-60-tr text-14">
353353
{React.string("Enter some language construct you want to know more about.")}
354354
</div>
355+
<p className="text-11 text-gray-70 mt-14 md:mt-4">
356+
{React.string("You are viewing docs for an older version of ReScript.")}
357+
</p>
358+
<a href="https://rescript-lang.org/syntax-lookup" className="text-11 text-fire underline">
359+
{React.string("Go to the latest version.")}
360+
</a>
355361
</div>
356-
<div className="w-full max-w-[34rem]">
362+
<div className="w-full max-w-[34rem] mt-8">
357363
<SearchBox
358364
placeholder="Enter keywords or syntax..."
359365
completionValues={Array.map(completionItems, item => item.name)}

src/common/Util.res

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ let removeVersionFromPathname = (pathname: string) =>
8484
pathname
8585
->Stdlib.String.split("/")
8686
->Array.filter(s => {
87-
let isVersion = s->Stdlib.String.includes("v") && s->Stdlib.String.includes(".")
87+
let isVersion =
88+
(s->Stdlib.String.includes("v") && s->Stdlib.String.includes(".")) ||
89+
s == "latest" ||
90+
s == "next"
8891
!isVersion
8992
})
9093
->Array.join("/")

src/layouts/SidebarLayout.res

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,6 @@ module Sidebar = {
133133
None
134134
}
135135

136-
let {pathname} = Next.Router.useRouter()
137-
138136
<>
139137
<div
140138
id="sidebar"
@@ -152,16 +150,7 @@ module Sidebar = {
152150
className="md:hidden h-16 flex pt-2 right-4 absolute">
153151
<Icon.Close />
154152
</button>
155-
<div className="mb-4">
156-
<p className="text-11">
157-
{React.string("You are viewing an older version of the documentation.")}
158-
</p>
159-
<a
160-
className="text-11 text-fire-30 border-b border-fire"
161-
href={`https://rescript-lang.org${pathname->Util.removeVersionFromPathname}`}>
162-
{React.string("Go to the latest version.")}
163-
</a>
164-
</div>
153+
165154
<div className="flex justify-between">
166155
<div className="w-3/4 md:w-full"> toplevelNav </div>
167156
</div>
@@ -252,6 +241,8 @@ let make = (
252241
setSidebarOpen(prev => !prev)
253242
}
254243

244+
let pathname = router.pathname
245+
255246
React.useEffect(() => {
256247
open Next.Router.Events
257248
let {Next.Router.events: events} = router
@@ -338,12 +329,13 @@ let make = (
338329
</div>
339330
</div>
340331
<p className="text-11 text-gray-70 mt-14 md:mt-4">
341-
<a href="">
342-
{React.string("You are viewing docs for an older version of Rescript.")}
343-
<br />
344-
{React.string("Go to latest version.")}
345-
</a>
332+
{React.string("You are viewing docs for an older version of ReScript.")}
346333
</p>
334+
<a
335+
href={`https://rescript-lang.org${pathname->Util.removeVersionFromPathname}`}
336+
className="text-11 text-fire underline">
337+
{React.string("Go to the latest version.")}
338+
</a>
347339
<div className={hasBreadcrumbs ? "mt-10" : "mt-6 md:-mt-4"}>
348340
<MdxProvider components> children </MdxProvider>
349341
</div>

0 commit comments

Comments
 (0)