mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-30 17:37:09 +02:00
fix(v2): hide past versions if it does not exist (#2050)
This commit is contained in:
parent
421f862701
commit
82c751f092
1 changed files with 29 additions and 28 deletions
|
@ -19,6 +19,7 @@ function Version() {
|
|||
const context = useDocusaurusContext();
|
||||
const {siteConfig = {}} = context;
|
||||
const latestVersion = versions[0];
|
||||
const pastVersions = versions.filter(version => version !== latestVersion);
|
||||
const repoUrl = `https://github.com/${siteConfig.organizationName}/${siteConfig.projectName}`;
|
||||
return (
|
||||
<Layout
|
||||
|
@ -65,34 +66,34 @@ function Version() {
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="margin-bottom--lg">
|
||||
<h3 id="archive">Past Versions</h3>
|
||||
<p>
|
||||
Here you can find documentation for previous versions of Docusaurus.
|
||||
</p>
|
||||
<table>
|
||||
<tbody>
|
||||
{versions.map(
|
||||
version =>
|
||||
version !== latestVersion && (
|
||||
<tr key={version}>
|
||||
<th>{version}</th>
|
||||
<td>
|
||||
<Link to={useBaseUrl(`/docs/${version}/introduction`)}>
|
||||
Documentation
|
||||
</Link>
|
||||
</td>
|
||||
<td>
|
||||
<a href={`${repoUrl}/releases/tag/v${version}`}>
|
||||
Release Notes
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{pastVersions.length > 0 && (
|
||||
<div className="margin-bottom--lg">
|
||||
<h3 id="archive">Past Versions</h3>
|
||||
<p>
|
||||
Here you can find documentation for previous versions of
|
||||
Docusaurus.
|
||||
</p>
|
||||
<table>
|
||||
<tbody>
|
||||
{pastVersions.map(version => (
|
||||
<tr key={version}>
|
||||
<th>{version}</th>
|
||||
<td>
|
||||
<Link to={useBaseUrl(`/docs/${version}/introduction`)}>
|
||||
Documentation
|
||||
</Link>
|
||||
</td>
|
||||
<td>
|
||||
<a href={`${repoUrl}/releases/tag/v${version}`}>
|
||||
Release Notes
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue