Skip to content

Commit ac97f5c

Browse files
authored
docs: updated versions doc (#308)
* add in versions * Update version matching and links * fix past version
1 parent 8e2349f commit ac97f5c

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

website/docusaurus.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const config: Config = {
3535
organizationName: 'NearForm',
3636
customFields: {
3737
pastOrganizationName: 'FormidableLabs',
38-
latestMinorVersions: ['0.7.5', '1.0.1'], // this is the latest patch version for each minor version
38+
latestMinorVersions: ['0.7.5', '1.0.1', '1.1.4', '1.2.0'], // this is the latest patch version for each minor version
3939
},
4040
projectName: 'react-native-ama',
4141

@@ -53,7 +53,7 @@ const config: Config = {
5353
lastVersion: 'current',
5454
versions: {
5555
current: {
56-
label: '1.0.x',
56+
label: '1.2.x',
5757
// path: '1.0.x',
5858
},
5959
},

website/src/pages/versions.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,21 @@ export default function Version(): JSX.Element {
3535
version => version !== latestVersion && version.name !== 'current',
3636
);
3737

38-
function matchVersion(wildCardVersion: string) {
38+
function matchPastVersion(wildCardVersion: string) {
3939
const regex = new RegExp('^' + wildCardVersion.replace('.x', '\\.'));
4040

4141
return (customFields?.latestMinorVersions as string[]).filter(version =>
4242
regex.test(version),
4343
);
4444
}
45+
function matchCurrentVersion(wildCardVersion: string) {
46+
const regex = new RegExp('^' + wildCardVersion.replace('.x', '\\.'));
47+
48+
const foundVersion = (customFields?.latestMinorVersions as string[]).find(
49+
version => regex.test(version),
50+
);
51+
return foundVersion ? `?q="%40${foundVersion}"` : '';
52+
}
4553

4654
const repoUrl = `https://github.com/${customFields?.pastOrganizationName}/${projectName}`;
4755

@@ -79,9 +87,7 @@ export default function Version(): JSX.Element {
7987
</td>
8088
<td>
8189
<Link
82-
to={`${repoUrl}/releases/tag/v${matchVersion(
83-
latestVersion.name,
84-
)}`}>
90+
to={`${repoUrl}/releases${matchCurrentVersion(latestVersion.label)}`}>
8591
<ReleaseNotesLabel />
8692
</Link>
8793
</td>
@@ -143,8 +149,8 @@ export default function Version(): JSX.Element {
143149
</td>
144150
<td>
145151
<Link
146-
href={`${repoUrl}/releases/tag/v${matchVersion(
147-
version.name,
152+
href={`${repoUrl}/releases/tag/v${matchPastVersion(
153+
version.label,
148154
)}`}>
149155
<ReleaseNotesLabel />
150156
</Link>

0 commit comments

Comments
 (0)