Skip to content

Enable versioned docs #1106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions website/pages/en/versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const React = require('react');

const CompLibrary = require('../../core/CompLibrary');

const Container = CompLibrary.Container;

const CWD = process.cwd();

const siteConfig = require(`${CWD}/siteConfig.js`);
const versions = require(`${CWD}/versions.json`);

const versionToReleaseTags = {
'5.x': '5.0.0',
'6.x': '6.0.0',
'7.x': '7.0.0-beta.0'
}

function Versions() {
const latestVersion = versions[0];
const repoUrl = `https://github.com/${siteConfig.organizationName}/${
siteConfig.projectName
}`;
const releaseTagUrl = version => versionToReleaseTags.hasOwnProperty(version) ? `${repoUrl}/releases/tag/v${versionToReleaseTags[version]}` : `${repoUrl}/releases/tag/v${version}`
return (
<div className="docMainWrapper wrapper">
<Container className="mainContainer versionsContainer">
<div className="post">
<header className="postHeader">
<h1>{siteConfig.title} Versions</h1>
</header>
<p>New versions of this project are released every so often.</p>
<h3 id="latest">Current version (Stable)</h3>
<table className="versions">
<tbody>
<tr>
<th>{latestVersion}</th>
<td>
<a href="/introduction/quick-start">Documentation</a>
</td>
<td>
<a href={releaseTagUrl(latestVersion)}>Release Notes</a>
</td>
</tr>
</tbody>
</table>
<p>
This is the version that is configured automatically when you first
install this project.
</p>
{
!!siteConfig.nextVersion && (<React.Fragment>
<h3 id="rc">Pre-release versions</h3>
<table className="versions">
<tbody>
<tr>
<th>{siteConfig.nextVersion}</th>
<td>
<a href={`/next/introduction/quick-start`}>Documentation</a>
</td>
<td>
<a href={releaseTagUrl(siteConfig.nextVersion)}>Release Notes</a>
</td>
</tr>
</tbody>
</table>
</React.Fragment>)
}
<h3 id="archive">Past Versions</h3>
<table className="versions">
<tbody>
{versions.map(
version =>
version !== latestVersion && (
<tr key={`version-${version}`}>
<th>{version}</th>
<td>
<a href={`${version}/introduction/quick-start`}>Documentation</a>
</td>
<td>
<a href={releaseTagUrl(version)}>Release Notes</a>
</td>
</tr>
),
)}
</tbody>
</table>
<p>
You can find past versions of this project on{' '}
<a href={repoUrl}>GitHub</a>.
</p>
</div>
</Container>
</div>
);
}

module.exports = Versions;
9 changes: 9 additions & 0 deletions website/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ const siteConfig = {
// template. For example, if you need your repo's URL...
repoUrl: "https://github.com/reduxjs/react-redux",

/**
* Note:
* This will generate a link on the versioned docs page for "pre-release versions"
* Once next version is released, run "yarn run version 7.x", and docusaurus will add 7.x to stable version
* After that, 7.x will no longer appear in "pre-release" versions and we should remove this line
* More info: https://docusaurus.io/docs/en/versioning
*/
nextVersion: "7.x",

gaTrackingId : "UA-130598673-2",
};

Expand Down
Loading