Skip to content

Commit 3981ffe

Browse files
authored
Add versions page and nav version (#6814)
* Add versions page and nav version * Move version to siteConfig.js * Fix typo * Set to 18.3.1, use siteConfig in reference sidebar * Redirect 18.react.dev to react.dev for now * Fix stray bullet
1 parent 9c53b48 commit 3981ffe

File tree

7 files changed

+347
-5
lines changed

7 files changed

+347
-5
lines changed

src/components/Layout/Sidebar/SidebarRouteTree.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {SidebarLink} from './SidebarLink';
1010
import {useCollapse} from 'react-collapsed';
1111
import usePendingRoute from 'hooks/usePendingRoute';
1212
import type {RouteItem} from 'components/Layout/getRouteMeta';
13+
import {siteConfig} from 'siteConfig';
1314

1415
interface SidebarRouteTreeProps {
1516
isForceExpanded: boolean;
@@ -150,8 +151,12 @@ export function SidebarRouteTree({
150151
);
151152
}
152153
if (hasSectionHeader) {
154+
let sectionHeaderText =
155+
sectionHeader != null
156+
? sectionHeader.replace('{{version}}', siteConfig.version)
157+
: '';
153158
return (
154-
<Fragment key={`${sectionHeader}-${level}-separator`}>
159+
<Fragment key={`${sectionHeaderText}-${level}-separator`}>
155160
{index !== 0 && (
156161
<li
157162
role="separator"
@@ -163,7 +168,7 @@ export function SidebarRouteTree({
163168
'mb-1 text-sm font-bold ms-5 text-tertiary dark:text-tertiary-dark',
164169
index !== 0 && 'mt-2'
165170
)}>
166-
{sectionHeader}
171+
{sectionHeaderText}
167172
</h3>
168173
</Fragment>
169174
);

src/components/Layout/TopNav/TopNav.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {Logo} from '../../Logo';
2424
import {Feedback} from '../Feedback';
2525
import {SidebarRouteTree} from '../Sidebar';
2626
import type {RouteItem} from '../getRouteMeta';
27+
import {siteConfig} from 'siteConfig';
2728

2829
declare global {
2930
interface Window {
@@ -247,7 +248,7 @@ export default function TopNav({
247248
)}>
248249
{isMenuOpen ? <IconClose /> : <IconHamburger />}
249250
</button>
250-
<div className="flex 3xl:flex-1 align-center">
251+
<div className="f">
251252
<NextLink
252253
href="/"
253254
className={`active:scale-95 overflow-hidden transition-transform relative items-center text-primary dark:text-primary-dark p-1 whitespace-nowrap outline-link rounded-full 3xl:rounded-xl inline-flex text-lg font-normal gap-2`}>
@@ -259,6 +260,13 @@ export default function TopNav({
259260
<span className="sr-only 3xl:not-sr-only">React</span>
260261
</NextLink>
261262
</div>
263+
<div className="flex flex-column justify-center items-center">
264+
<NextLink
265+
href="/versions"
266+
className=" flex py-2 flex-column justify-center items-center text-gray-50 dark:text-gray-30 hover:text-link hover:dark:text-link-dark hover:underline text-sm ms-1 cursor-pointer">
267+
v{siteConfig.version}
268+
</NextLink>
269+
</div>
262270
</div>
263271
<div className="items-center justify-center flex-1 hidden w-full md:flex 3xl:w-auto 3xl:shrink-0 3xl:justify-center">
264272
<button

src/content/community/versioning-policy.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ All stable builds of React go through a high level of testing and follow semanti
88

99
</Intro>
1010

11+
For a list of previous releases, see the [Versions](/versions) page.
12+
1113
## Stable releases {/*stable-releases*/}
1214

1315
Stable React releases (also known as "Latest" release channel) follow [semantic versioning (semver)](https://semver.org/) principles.

src/content/versions.md

+282
Large diffs are not rendered by default.

src/sidebarReference.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"routes": [
55
{
66
"hasSectionHeader": true,
7-
"sectionHeader": "react@18.2.0"
7+
"sectionHeader": "react@{{version}}"
88
},
99
{
1010
"title": "Overview",
@@ -156,7 +156,7 @@
156156
},
157157
{
158158
"hasSectionHeader": true,
159-
"sectionHeader": "react-dom@18.2.0"
159+
"sectionHeader": "react-dom@{{version}}"
160160
},
161161
{
162162
"title": "Hooks",

src/siteConfig.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
exports.siteConfig = {
6+
version: '18.3.1',
67
// --------------------------------------
78
// Translations should replace these lines:
89
languageCode: 'en',

vercel.json

+44
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,50 @@
44
},
55
"trailingSlash": false,
66
"redirects": [
7+
{
8+
"source": "/",
9+
"has": [
10+
{
11+
"type": "host",
12+
"value": "18.react.dev"
13+
}
14+
],
15+
"permanent": false,
16+
"destination": "https://react.dev/"
17+
},
18+
{
19+
"source": "/",
20+
"has": [
21+
{
22+
"type": "host",
23+
"value": "17.react.dev"
24+
}
25+
],
26+
"permanent": true,
27+
"destination": "https://17.reactjs.org/"
28+
},
29+
{
30+
"source": "/",
31+
"has": [
32+
{
33+
"type": "host",
34+
"value": "16.react.dev"
35+
}
36+
],
37+
"permanent": true,
38+
"destination": "https://17.reactjs.org/"
39+
},
40+
{
41+
"source": "/",
42+
"has": [
43+
{
44+
"type": "host",
45+
"value": "15.react.dev"
46+
}
47+
],
48+
"permanent": true,
49+
"destination": "https://react-legacy.netlify.app/"
50+
},
751
{
852
"source": "/reference",
953
"destination": "/reference/react",

0 commit comments

Comments
 (0)