fix(v2): hide past versions if it does not exist (#2050)

This commit is contained in:
Alexey Pyltsyn 2019-11-25 12:16:23 +03:00 committed by Endi
parent 421f862701
commit 82c751f092

View file

@ -19,6 +19,7 @@ function Version() {
const context = useDocusaurusContext(); const context = useDocusaurusContext();
const {siteConfig = {}} = context; const {siteConfig = {}} = context;
const latestVersion = versions[0]; const latestVersion = versions[0];
const pastVersions = versions.filter(version => version !== latestVersion);
const repoUrl = `https://github.com/${siteConfig.organizationName}/${siteConfig.projectName}`; const repoUrl = `https://github.com/${siteConfig.organizationName}/${siteConfig.projectName}`;
return ( return (
<Layout <Layout
@ -65,34 +66,34 @@ function Version() {
</tbody> </tbody>
</table> </table>
</div> </div>
<div className="margin-bottom--lg"> {pastVersions.length > 0 && (
<h3 id="archive">Past Versions</h3> <div className="margin-bottom--lg">
<p> <h3 id="archive">Past Versions</h3>
Here you can find documentation for previous versions of Docusaurus. <p>
</p> Here you can find documentation for previous versions of
<table> Docusaurus.
<tbody> </p>
{versions.map( <table>
version => <tbody>
version !== latestVersion && ( {pastVersions.map(version => (
<tr key={version}> <tr key={version}>
<th>{version}</th> <th>{version}</th>
<td> <td>
<Link to={useBaseUrl(`/docs/${version}/introduction`)}> <Link to={useBaseUrl(`/docs/${version}/introduction`)}>
Documentation Documentation
</Link> </Link>
</td> </td>
<td> <td>
<a href={`${repoUrl}/releases/tag/v${version}`}> <a href={`${repoUrl}/releases/tag/v${version}`}>
Release Notes Release Notes
</a> </a>
</td> </td>
</tr> </tr>
), ))}
)} </tbody>
</tbody> </table>
</table> </div>
</div> )}
</div> </div>
</Layout> </Layout>
); );