aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2024-04-30 08:09:44 +0200
committerGitHub <[email protected]>2024-04-30 06:09:44 +0000
commit13dc42054abc6188c314acf98cec73f0283072c2 (patch)
treea9e94768717a15119065f7b9aed9b196ea579445 /docs
parentb87acb8e415414aa9463838b28a70818b969db8f (diff)
downloadfaker-13dc42054abc6188c314acf98cec73f0283072c2.tar.xz
faker-13dc42054abc6188c314acf98cec73f0283072c2.zip
docs: link to the latest release of the current version (#2856)
Diffstat (limited to 'docs')
-rw-r--r--docs/.vitepress/config.ts4
-rw-r--r--docs/.vitepress/versions.ts24
2 files changed, 9 insertions, 19 deletions
diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts
index 3bb9c935..b226f441 100644
--- a/docs/.vitepress/config.ts
+++ b/docs/.vitepress/config.ts
@@ -4,8 +4,8 @@ import { apiPages } from './api-pages';
import {
algoliaIndex,
currentVersion,
- oldVersions,
versionBannerInfix,
+ versionLinks,
} from './versions';
type SidebarItem = DefaultTheme.SidebarItem;
@@ -225,7 +225,7 @@ const config: UserConfig<DefaultTheme.Config> = {
text: 'Release Notes',
link: 'https://github.com/faker-js/faker/releases',
},
- ...oldVersions.map(({ version, link }) => ({
+ ...versionLinks.map(({ version, link }) => ({
text: version,
link,
})),
diff --git a/docs/.vitepress/versions.ts b/docs/.vitepress/versions.ts
index a44b65c3..9d693e3d 100644
--- a/docs/.vitepress/versions.ts
+++ b/docs/.vitepress/versions.ts
@@ -9,17 +9,13 @@ function readBranchName(): string {
}
function readOtherLatestReleaseTagNames(): string[] {
- const currentMajorVersion = semver.major(version);
const latestReleaseTagNames = execSync('git tag -l')
.toString('utf8')
.split('\n')
.filter((tag) => semver.valid(tag))
- .filter((tag) => {
- // Only consider tags for our deployed website versions,
- // excluding the current major version.
- const majorVersion = semver.major(tag);
- return majorVersion >= 6 && majorVersion !== currentMajorVersion;
- })
+ // Only consider tags for our deployed website versions
+ .filter((tag) => semver.major(tag) >= 6)
+ // Find the latest tag for each major version
.reduce<Record<number, string>>((latestTagByMajor, tag) => {
const majorVersion = semver.major(tag);
@@ -39,10 +35,6 @@ const {
BRANCH: branchName = readBranchName(),
} = process.env;
-const hiddenLink =
- deployContext === 'production'
- ? 'https://fakerjs.dev/'
- : `https://${branchName}.fakerjs.dev/`;
const otherVersions = readOtherLatestReleaseTagNames();
const isReleaseBranch = /^v\d+$/.test(branchName);
@@ -60,11 +52,7 @@ export const versionBannerInfix: string | null = (() => {
})();
export const currentVersion = isReleaseBranch ? `v${version}` : branchName;
-export const oldVersions = [
- {
- version: 'latest',
- link: 'https://fakerjs.dev/',
- },
+export const versionLinks = [
{
version: 'next',
link: 'https://next.fakerjs.dev/',
@@ -73,7 +61,9 @@ export const oldVersions = [
version,
link: `https://v${semver.major(version)}.fakerjs.dev/`,
})),
-].filter(({ link }) => link !== hiddenLink);
+]
+ // Don't link to the current branch's version.
+ .filter(({ link }) => link !== `https://${branchName}.fakerjs.dev/`);
export const algoliaIndex = isReleaseBranch
? `fakerjs-v${semver.major(version)}`