Skip to content

Commit 87b4b10

Browse files
committed
added latest version disclaimer
1 parent 5d1a87e commit 87b4b10

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/common/Util.res

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,11 @@ module Date = {
7979
dateTimeFormat("en-US", {"month": "short", "day": "numeric", "year": "numeric"})->format(date)
8080
}
8181
}
82+
83+
84+
let removeVersionFromPathname = (pathname: string) =>
85+
pathname->Stdlib.String.split("/")->Array.filter(s => {
86+
let isVersion = s->Stdlib.String.includes("v") && s->Stdlib.String.includes(".")
87+
!isVersion
88+
})
89+
->Array.join("/")

src/common/Util.resi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ module String: {
1414
module Date: {
1515
let toDayMonthYear: Date.t => string
1616
}
17+
18+
19+
let removeVersionFromPathname: string => string

src/layouts/SidebarLayout.res

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,15 @@ module Sidebar = {
133133
None
134134
}
135135

136-
<>
136+
let { pathname } = Next.Router.useRouter()
137+
138+
<>
137139
<div
138140
id="sidebar"
139141
className={(
140142
isOpen ? "fixed w-full left-0 h-full z-20 min-w-320" : "hidden "
141143
) ++ " md:block md:w-48 md:-ml-4 lg:w-1/5 h-auto md:relative overflow-y-visible bg-white mt-28 md:mt-0"}>
144+
142145
<aside
143146
id="sidebar-content"
144147
className="relative top-0 px-4 w-full block md:pt-10 md:top-[7rem] md:sticky border-r border-gray-20 overflow-y-auto pb-24 h-auto max-h-[calc(100vh-7rem)]">
@@ -150,6 +153,10 @@ module Sidebar = {
150153
className="md:hidden h-16 flex pt-2 right-4 absolute">
151154
<Icon.Close />
152155
</button>
156+
<div className="mb-4">
157+
<p className="text-11">{React.string("You are viewing an older version of the documentation.")}</p>
158+
<a className="text-11 text-fire-30 border-b border-fire" href={`https://rescript-lang.org${pathname->Util.removeVersionFromPathname}`}>{React.string("Go to the latest version.")}</a>
159+
</div>
153160
<div className="flex justify-between">
154161
<div className="w-3/4 md:w-full"> toplevelNav </div>
155162
</div>

0 commit comments

Comments
 (0)