Skip to content

Commit

Permalink
docs: updated versions doc (#308)
Browse files Browse the repository at this point in the history
* add in versions

* Update version matching and links

* fix past version
  • Loading branch information
JDMathew authored Jan 23, 2025
1 parent 8e2349f commit ac97f5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions website/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const config: Config = {
organizationName: 'NearForm',
customFields: {
pastOrganizationName: 'FormidableLabs',
latestMinorVersions: ['0.7.5', '1.0.1'], // this is the latest patch version for each minor version
latestMinorVersions: ['0.7.5', '1.0.1', '1.1.4', '1.2.0'], // this is the latest patch version for each minor version
},
projectName: 'react-native-ama',

Expand All @@ -53,7 +53,7 @@ const config: Config = {
lastVersion: 'current',
versions: {
current: {
label: '1.0.x',
label: '1.2.x',
// path: '1.0.x',
},
},
Expand Down
18 changes: 12 additions & 6 deletions website/src/pages/versions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@ export default function Version(): JSX.Element {
version => version !== latestVersion && version.name !== 'current',
);

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

return (customFields?.latestMinorVersions as string[]).filter(version =>
regex.test(version),
);
}
function matchCurrentVersion(wildCardVersion: string) {
const regex = new RegExp('^' + wildCardVersion.replace('.x', '\\.'));

const foundVersion = (customFields?.latestMinorVersions as string[]).find(
version => regex.test(version),
);
return foundVersion ? `?q="%40${foundVersion}"` : '';
}

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

Expand Down Expand Up @@ -79,9 +87,7 @@ export default function Version(): JSX.Element {
</td>
<td>
<Link
to={`${repoUrl}/releases/tag/v${matchVersion(
latestVersion.name,
)}`}>
to={`${repoUrl}/releases${matchCurrentVersion(latestVersion.label)}`}>
<ReleaseNotesLabel />
</Link>
</td>
Expand Down Expand Up @@ -143,8 +149,8 @@ export default function Version(): JSX.Element {
</td>
<td>
<Link
href={`${repoUrl}/releases/tag/v${matchVersion(
version.name,
href={`${repoUrl}/releases/tag/v${matchPastVersion(
version.label,
)}`}>
<ReleaseNotesLabel />
</Link>
Expand Down

0 comments on commit ac97f5c

Please sign in to comment.