This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-website.git
The following commit(s) were added to refs/heads/master by this push:
new 4db177c0cdd feat: allow use other name to replace origin version
(#1349)
4db177c0cdd is described below
commit 4db177c0cdd2f743f5ddd14a4567918bc5ce1d48
Author: Young <[email protected]>
AuthorDate: Wed Sep 28 16:09:12 2022 +0800
feat: allow use other name to replace origin version (#1349)
---
config/apisix-versions.js | 11 ++++++++++-
scripts/sync-docs.js | 11 ++++++-----
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/config/apisix-versions.js b/config/apisix-versions.js
index 9ea6d31a327..13766f9f34f 100644
--- a/config/apisix-versions.js
+++ b/config/apisix-versions.js
@@ -10,6 +10,13 @@ const versions = ['2.12', '2.13', '2.14', '2.15', '2.99'];
*/
const LTSVersions = ['2.15'];
+/**
+ * @type {{[origin: string]: string}} version display name mapping to origin
name
+ */
+const versionMap = {
+ '2.99': '3.0.0-beta',
+};
+
/**
* @type {Array<{label: string, href: string}>}
*/
@@ -48,4 +55,6 @@ const archivedVersions = [
},
];
-module.exports = { versions, LTSVersions, archivedVersions };
+module.exports = {
+ versions, LTSVersions, versionMap, archivedVersions,
+};
diff --git a/scripts/sync-docs.js b/scripts/sync-docs.js
index f5e328c5371..d5fc18aa00f 100644
--- a/scripts/sync-docs.js
+++ b/scripts/sync-docs.js
@@ -10,7 +10,7 @@ const semver = require('semver');
const replace = require('replace-in-file');
const common = require('./common.js');
-const { versions } = require('../config/apisix-versions.js');
+const { versions, versionMap } = require('../config/apisix-versions.js');
const { projects, languages, projectPaths } = common;
const tempPath = './temp';
@@ -94,7 +94,7 @@ const tasks = new Listr([
if (versions.length === 0) return Promise.resolve();
if (await isFileExisted(target)) await fs.rm(target);
- return fs.writeFile(target, JSON.stringify(versions.reverse(), null,
2));
+ return fs.writeFile(target, JSON.stringify(versions.map((v) =>
versionMap[v] || v).reverse(), null, 2));
};
const extractTasks = projectPaths.map((project) => ({
@@ -354,8 +354,9 @@ function extractDocsVersionTasks(project, version) {
const docsPath = `${projectPath}/docs`;
const enSrcDocs = `${docsPath}/en/latest`;
const zhSrcDocs = `${docsPath}/zh/latest`;
- const enTargetDocs =
`${websitePath}/docs-${projectName}_versioned_docs/version-${version}`;
- const zhTargetDocs =
`${websitePath}/i18n/zh/docusaurus-plugin-content-docs-docs-${projectName}/version-${version}`;
+ const displayVersionName = (projectName === 'apisix' &&
versionMap?.[version]) || version;
+ const enTargetDocs =
`${websitePath}/docs-${projectName}_versioned_docs/version-${displayVersionName}`;
+ const zhTargetDocs =
`${websitePath}/i18n/zh/docusaurus-plugin-content-docs-docs-${projectName}/version-${displayVersionName}`;
await Promise.allSettled([
copyDocs(enSrcDocs, enTargetDocs)
@@ -363,7 +364,7 @@ function extractDocsVersionTasks(project, version) {
.then(() => handleConfig2Sidebar(
enTargetDocs,
enTargetDocs,
- version,
+ displayVersionName,
`${websitePath}/docs-${project.name}_versioned_sidebars`,
)),
copyDocs(zhSrcDocs, zhTargetDocs).then(() =>
replaceMDElements(projectName, [zhTargetDocs], branchName)),