mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-16 08:15:55 +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 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>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue