Skip to content

Commit eae14cc

Browse files
wgao19markerikson
authored andcommitted
Enable versioned docs (#1106)
* Enable versioned doc * Start adding 6.0 docs * Rename 5.1.1 to 5.x and make it work * Cast v6.x versioned docs * Display v7.x as pre-release version
1 parent 28adb54 commit eae14cc

26 files changed

+4939
-0
lines changed

website/pages/en/versions.js

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/**
2+
* Copyright (c) 2017-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
const React = require('react');
9+
10+
const CompLibrary = require('../../core/CompLibrary');
11+
12+
const Container = CompLibrary.Container;
13+
14+
const CWD = process.cwd();
15+
16+
const siteConfig = require(`${CWD}/siteConfig.js`);
17+
const versions = require(`${CWD}/versions.json`);
18+
19+
const versionToReleaseTags = {
20+
'5.x': '5.0.0',
21+
'6.x': '6.0.0',
22+
'7.x': '7.0.0-beta.0'
23+
}
24+
25+
function Versions() {
26+
const latestVersion = versions[0];
27+
const repoUrl = `https://github.com/${siteConfig.organizationName}/${
28+
siteConfig.projectName
29+
}`;
30+
const releaseTagUrl = version => versionToReleaseTags.hasOwnProperty(version) ? `${repoUrl}/releases/tag/v${versionToReleaseTags[version]}` : `${repoUrl}/releases/tag/v${version}`
31+
return (
32+
<div className="docMainWrapper wrapper">
33+
<Container className="mainContainer versionsContainer">
34+
<div className="post">
35+
<header className="postHeader">
36+
<h1>{siteConfig.title} Versions</h1>
37+
</header>
38+
<p>New versions of this project are released every so often.</p>
39+
<h3 id="latest">Current version (Stable)</h3>
40+
<table className="versions">
41+
<tbody>
42+
<tr>
43+
<th>{latestVersion}</th>
44+
<td>
45+
<a href="/introduction/quick-start">Documentation</a>
46+
</td>
47+
<td>
48+
<a href={releaseTagUrl(latestVersion)}>Release Notes</a>
49+
</td>
50+
</tr>
51+
</tbody>
52+
</table>
53+
<p>
54+
This is the version that is configured automatically when you first
55+
install this project.
56+
</p>
57+
{
58+
!!siteConfig.nextVersion && (<React.Fragment>
59+
<h3 id="rc">Pre-release versions</h3>
60+
<table className="versions">
61+
<tbody>
62+
<tr>
63+
<th>{siteConfig.nextVersion}</th>
64+
<td>
65+
<a href={`/next/introduction/quick-start`}>Documentation</a>
66+
</td>
67+
<td>
68+
<a href={releaseTagUrl(siteConfig.nextVersion)}>Release Notes</a>
69+
</td>
70+
</tr>
71+
</tbody>
72+
</table>
73+
</React.Fragment>)
74+
}
75+
<h3 id="archive">Past Versions</h3>
76+
<table className="versions">
77+
<tbody>
78+
{versions.map(
79+
version =>
80+
version !== latestVersion && (
81+
<tr key={`version-${version}`}>
82+
<th>{version}</th>
83+
<td>
84+
<a href={`${version}/introduction/quick-start`}>Documentation</a>
85+
</td>
86+
<td>
87+
<a href={releaseTagUrl(version)}>Release Notes</a>
88+
</td>
89+
</tr>
90+
),
91+
)}
92+
</tbody>
93+
</table>
94+
<p>
95+
You can find past versions of this project on{' '}
96+
<a href={repoUrl}>GitHub</a>.
97+
</p>
98+
</div>
99+
</Container>
100+
</div>
101+
);
102+
}
103+
104+
module.exports = Versions;

website/siteConfig.js

+9
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ const siteConfig = {
9898
// template. For example, if you need your repo's URL...
9999
repoUrl: "https://github.com/reduxjs/react-redux",
100100

101+
/**
102+
* Note:
103+
* This will generate a link on the versioned docs page for "pre-release versions"
104+
* Once next version is released, run "yarn run version 7.x", and docusaurus will add 7.x to stable version
105+
* After that, 7.x will no longer appear in "pre-release" versions and we should remove this line
106+
* More info: https://docusaurus.io/docs/en/versioning
107+
*/
108+
nextVersion: "7.x",
109+
101110
gaTrackingId : "UA-130598673-2",
102111
};
103112

0 commit comments

Comments
 (0)