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,16 +66,16 @@ function Version() {
</tbody> </tbody>
</table> </table>
</div> </div>
{pastVersions.length > 0 && (
<div className="margin-bottom--lg"> <div className="margin-bottom--lg">
<h3 id="archive">Past Versions</h3> <h3 id="archive">Past Versions</h3>
<p> <p>
Here you can find documentation for previous versions of Docusaurus. Here you can find documentation for previous versions of
Docusaurus.
</p> </p>
<table> <table>
<tbody> <tbody>
{versions.map( {pastVersions.map(version => (
version =>
version !== latestVersion && (
<tr key={version}> <tr key={version}>
<th>{version}</th> <th>{version}</th>
<td> <td>
@ -88,11 +89,11 @@ function Version() {
</a> </a>
</td> </td>
</tr> </tr>
), ))}
)}
</tbody> </tbody>
</table> </table>
</div> </div>
)}
</div> </div>
</Layout> </Layout>
); );