-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
/
versions.tsx
197 lines (187 loc) · 6.19 KB
/
versions.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {ReactNode} from 'react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import Link from '@docusaurus/Link';
import Translate from '@docusaurus/Translate';
import {
useVersions,
useLatestVersion,
} from '@docusaurus/plugin-content-docs/client';
import Layout from '@theme/Layout';
import Heading from '@theme/Heading';
import VersionsArchived from '@site/versionsArchived.json';
const docsPluginId = undefined; // Default docs plugin instance
const VersionsArchivedList = Object.entries(VersionsArchived);
function DocumentationLabel() {
return (
<Translate id="versionsPage.versionEntry.link">Documentation</Translate>
);
}
function ReleaseNotesLabel() {
return (
<Translate id="versionsPage.versionEntry.releaseNotes">
Release Notes
</Translate>
);
}
export default function Version(): ReactNode {
const {
siteConfig: {organizationName, projectName},
} = useDocusaurusContext();
const versions = useVersions(docsPluginId);
const latestVersion = useLatestVersion(docsPluginId);
const currentVersion = versions.find(
(version) => version.name === 'current',
)!;
const pastVersions = versions.filter(
(version) => version !== latestVersion && version.name !== 'current',
);
const repoUrl = `https://github.com/${organizationName!}/${projectName!}`;
return (
<Layout
title="Versions"
description="Docusaurus 2 Versions page listing all documented site versions">
<main className="container margin-vert--lg">
<Heading as="h1">
<Translate id="versionsPage.title">
Docusaurus documentation versions
</Translate>
</Heading>
<div className="margin-bottom--lg">
<Heading as="h3" id="next">
<Translate id="versionsPage.current.title">
Current version (Stable)
</Translate>
</Heading>
<p>
<Translate id="versionsPage.current.description">
Here you can find the documentation for current released version.
</Translate>
</p>
<table>
<tbody>
<tr>
<th>{latestVersion.label}</th>
<td>
<Link to={latestVersion.path}>
<DocumentationLabel />
</Link>
</td>
<td>
<Link to={`${repoUrl}/releases/tag/v${latestVersion.name}`}>
<ReleaseNotesLabel />
</Link>
</td>
</tr>
</tbody>
</table>
</div>
{currentVersion !== latestVersion && (
<div className="margin-bottom--lg">
<Heading as="h3" id="latest">
<Translate id="versionsPage.next.title">
Next version (Unreleased)
</Translate>
</Heading>
<p>
<Translate id="versionsPage.next.description">
Here you can find the documentation for work-in-process
unreleased version.
</Translate>
</p>
<table>
<tbody>
<tr>
<th>{currentVersion.label}</th>
<td>
<Link to={currentVersion.path}>
<DocumentationLabel />
</Link>
</td>
</tr>
</tbody>
</table>
</div>
)}
{(pastVersions.length > 0 || VersionsArchivedList.length > 0) && (
<div className="margin-bottom--lg">
<Heading as="h3" id="archive">
<Translate id="versionsPage.archived.title">
Past versions (Not maintained anymore)
</Translate>
</Heading>
<p>
<Translate id="versionsPage.archived.description">
Here you can find documentation for previous versions of
Docusaurus.
</Translate>
</p>
<table>
<tbody>
{pastVersions.map((version) => (
<tr key={version.name}>
<th>{version.label}</th>
<td>
<Link to={version.path}>
<DocumentationLabel />
</Link>
</td>
<td>
<Link href={`${repoUrl}/releases/tag/v${version.name}`}>
<ReleaseNotesLabel />
</Link>
</td>
</tr>
))}
{VersionsArchivedList.map(([versionName, versionUrl]) => (
<tr key={versionName}>
<th>{versionName}</th>
<td>
<Link to={versionUrl}>
<DocumentationLabel />
</Link>
</td>
<td>
<Link href={`${repoUrl}/releases/tag/v${versionName}`}>
<ReleaseNotesLabel />
</Link>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
<div className="margin-bottom--lg">
<Heading as="h3" id="legacy">
<Translate id="versionsPage.legacy.title">
Docusaurus v1 (Legacy)
</Translate>
</Heading>
<p>
<Translate id="versionsPage.legacy.description">
Here you can find documentation for legacy version of Docusaurus.
</Translate>
</p>
<table>
<tbody>
<tr>
<th>1.x</th>
<td>
<Link href="https://v1.docusaurus.io/docs/en/installation">
<DocumentationLabel />
</Link>
</td>
</tr>
</tbody>
</table>
</div>
</main>
</Layout>
);
}