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 b4b1643  chore: remove release & update navbar (#788)
b4b1643 is described below

commit b4b1643756ce647e7594dd994dc18cdf58b5d1e2
Author: 琚致远 <[email protected]>
AuthorDate: Thu Dec 2 22:47:42 2021 +0800

    chore: remove release & update navbar (#788)
---
 scripts/common.js            |  62 ++-----------------
 scripts/sync-docs.js         | 140 -------------------------------------------
 website/config/navbar.js     |  53 +++++-----------
 website/docusaurus.config.js |   8 ---
 4 files changed, 20 insertions(+), 243 deletions(-)

diff --git a/scripts/common.js b/scripts/common.js
index 0d31e10..b4cfbc9 100644
--- a/scripts/common.js
+++ b/scripts/common.js
@@ -2,26 +2,17 @@ const projects = [
   {
     name: "apisix-ingress-controller",
     branch: "master",
-    hasChangelog: true,
-    changelogExtractor: function (changelogs, targetRelease) {
-      return changelogExtractor(changelogs, targetRelease, "#", true);
-    }
+    hasChangelog: true
   },
   {
     name: "apisix",
     branch: "master",
-    hasChangelog: true,
-    changelogExtractor: function (changelogs, targetRelease) {
-      return changelogExtractor(changelogs, targetRelease, "##", false);
-    }
+    hasChangelog: true
   },
   {
     name: "apisix-dashboard",
     branch: "master",
-    hasChangelog: true,
-    changelogExtractor: function (changelogs, targetRelease) {
-      return changelogExtractor(changelogs, targetRelease, "#", false);
-    }
+    hasChangelog: true
   },
   {
     name: "apisix-docker",
@@ -36,63 +27,22 @@ const projects = [
   {
     name: "apisix-java-plugin-runner",
     branch: "main",
-    hasChangelog: true,
-    changelogExtractor: function (changelogs, targetRelease) {
-      return changelogExtractor(changelogs, targetRelease, "##", true);
-    }
+    hasChangelog: true
   },
   {
     name: "apisix-go-plugin-runner",
     branch: "master",
-    hasChangelog: true,
-    changelogExtractor: function (changelogs, targetRelease) {
-      return changelogExtractor(changelogs, targetRelease, "##", true);
-    }
+    hasChangelog: true
   },
   {
     name: "apisix-python-plugin-runner",
     branch: "master",
-    hasChangelog: true,
-    changelogExtractor: function (changelogs, targetRelease) {
-      return changelogExtractor(changelogs, targetRelease, "##", true);
-    }
+    hasChangelog: true
   }
 ];
 
 const languages = ["en", "zh", "es"];
 
-/**
- * changelog extractor for each version
- * @param {string} changelogs CHANGELOG.md contents
- * @param {Object} targetRelease result from GitHub API
- * @param {string} versionStartsWith version line markdown symbol
- * @param {boolean} reserveVersionEnds0 reserve the `.0` on version end (e.g. 
`.0` of `1.5.0`)
- */
-const changelogExtractor = (changelogs, targetRelease, versionStartsWith, 
reserveVersionEnds0) => {
-  const regex = new RegExp(`${versionStartsWith}.[0-9].[0-9].[0-9]`, "g");
-  const versions = changelogs.match(regex);
-
-  let changelog;
-  changelogs.split(regex)
-      .filter(item => item.indexOf("Table of Contents") === -1)
-      .forEach((log, index) => {
-        const targetVersion = targetRelease.tag_name.replace("v", "");
-        let version = versions[index].replace(`${versionStartsWith} `, "");
-        if (!reserveVersionEnds0 && version.endsWith(".0")) {
-          version = version.replace(".0", "");
-        }
-        if (targetVersion === version) {
-          changelog = {
-            version: targetVersion,
-            changelog: log,
-            releaseTime: targetRelease.published_at,
-          };
-        }
-      });
-
-  return changelog;
-}
-
 module.exports = {
   projects,
   languages,
diff --git a/scripts/sync-docs.js b/scripts/sync-docs.js
index 45458e9..dec9374 100644
--- a/scripts/sync-docs.js
+++ b/scripts/sync-docs.js
@@ -4,7 +4,6 @@ const path = require("path");
 const process = require("process");
 const listr = require("listr");
 const simpleGit = require("simple-git");
-const axios = require("axios");
 const semver = require('semver');
 
 const common = require("./common.js");
@@ -13,7 +12,6 @@ const common = require("./common.js");
 const git = simpleGit();
 const {projects, languages, projectPaths} = common;
 const tempPath = "./tmp";
-const releaseTempPath = `${tempPath}/releases`;
 const websitePath = "../website";
 
 const projectReleases = {};
@@ -148,122 +146,6 @@ const tasks = new listr([
     }
   },
   {
-    title: "Fetch project release logs",
-    task: () => {
-      const fetchReleaseLogTasks = projects.map((project) => {
-        if (!project.hasChangelog) {
-          return {
-            title: `Fetch ${project.name} release logs`,
-            skip: () => {
-              return `${project.name} has no changelog`;
-            },
-            task: () => {
-            }
-          }
-        }
-
-        const releaseURL = 
`https://api.github.com/repos/apache/${project.name}/releases`;
-        const changelogURL = 
`https://raw.githubusercontent.com/apache/${project.name}/${project.branch}/CHANGELOG.md`;
-
-        return {
-          title: `Fetch ${project.name} release logs`,
-          task: () => {
-            let releaseResult;
-            let changelogResult = '';
-            let changelogList = [];
-            const steps = [
-              {
-                title: `Fetch ${project.name}'s release list`,
-                task: async () => {
-                  try {
-                    releaseResult = (await axios.get(releaseURL)).data;
-                  } catch (e) {
-                    log(`Fetch ${project.name} release list failed: ` + e)
-                  }
-                }
-              },
-              {
-                title: `Fetch ${project.name}'s CHANGELOG.md`,
-                task: async () => {
-                  try {
-                    changelogResult = (await axios.get(changelogURL)).data;
-                  } catch (e) {
-                    log(`Fetch ${project.name} changelog failed: ` + e)
-                  }
-                }
-              },
-              {
-                title: "Extract changelog in CHANGELOG.md",
-                task: () => {
-                  releaseResult.forEach(item => {
-                    if ("changelogExtractor" in project) {
-                      let changelog = 
project.changelogExtractor(changelogResult, item);
-                      if (changelog) changelogList.push(changelog);
-                    }
-                  });
-                }
-              },
-              {
-                title: "Remove unsupport tags",
-                task: () => {
-                  const unsupportTags = {
-                    "<details>": "",
-                    "</details>": "",
-                    "<summary>": "",
-                    "</summary>": "",
-                    "<p>": "",
-                    "</p>": "",
-                  };
-
-                  changelogList = changelogList.map(item => {
-                    Object.keys(unsupportTags).forEach(tag => {
-                      if (item.changelog.includes(tag)) {
-                        item.changelog = item.changelog.replace(new 
RegExp(tag, "g"), unsupportTags[tag]);
-                      }
-                    });
-
-                    return item;
-                  });
-                }
-              },
-              {
-                title: "Generate Release Logs",
-                task: () => {
-                  if (!isFileExisted(releaseTempPath)) {
-                    removeFolder(releaseTempPath);
-                    fs.mkdirSync(releaseTempPath);
-                  }
-                  changelogList.forEach(item => {
-                    const releaseTime = new Date(item.releaseTime);
-                    const logName = 
`${releaseTime.getFullYear()}-${releaseTime.getMonth() + 
1}-${releaseTime.getDate()}-release-apache-${project.name}-${item.version}.md`;
-                    const humanProjectName = project.name.split("-").map(name 
=> {
-                      if (name === 'apisix') return name.toUpperCase();
-                      return name.charAt(0).toUpperCase() + name.slice(1);
-                    }).join(" ");
-                    const header = `---
-title: Release Apache ${humanProjectName} ${item.version}
-tags: 
-  - ${humanProjectName}
----\n\n`;
-                    fs.writeFileSync(`${releaseTempPath}/${logName}`, header + 
item.changelog);
-                  });
-                }
-              },
-              {
-                title: "Copy Release Logs to website",
-                task: () => {
-                  copyFolder(releaseTempPath, `${websitePath}/releases`);
-                }
-              },
-            ];
-            return new listr(steps);
-          }
-        }
-      });
-      return new listr(fetchReleaseLogTasks);
-    }
-  },
-  {
     title: "Clean temporary files",
     task: () => {
       removeFolder(tempPath);
@@ -414,25 +296,3 @@ const copyAllDocs = (project) => {
       "zh"
   );
 };
-
-const setup = () => {
-  log("Install dependencies");
-  childProcess.execSync("npm i --save replace-in-file listr");
-  //childProcess.execSync("npm install", {cwd: `./website`});
-
-  removeFolder("tmp");
-  fs.mkdirSync("tmp");
-};
-
-const clean = () => {
-  log("Delete tmp folder");
-  removeFolder("tmp");
-
-  log("Delete npm related files");
-  removeFolder("node_modules");
-  ["package.json", "package-lock.json"].forEach((file) => {
-    if (fs.existsSync(file)) {
-      fs.unlinkSync(file);
-    }
-  });
-};
diff --git a/website/config/navbar.js b/website/config/navbar.js
index 40d4d0c..8d7c27c 100644
--- a/website/config/navbar.js
+++ b/website/config/navbar.js
@@ -43,28 +43,6 @@ module.exports = [
     ],
   },
   {
-    label: "FAQ",
-    position: "right",
-    items: [
-      {
-        label: "Apache APISIX®",
-        to: "/docs/apisix/FAQ/",
-      },
-      {
-        label: "Apache APISIX® Dashboard",
-        to: "/docs/dashboard/FAQ/",
-      },
-      {
-        label: "Apache APISIX® Ingress Controller",
-        to: "/docs/ingress-controller/FAQ/",
-      },
-      {
-        label: "Apache APISIX® Helm Chart",
-        to: "/docs/helm-chart/FAQ/",
-      },
-    ]
-  },
-  {
     to: "/blog",
     label: "Blog",
     position: "right",
@@ -75,25 +53,32 @@ module.exports = [
     position: "right",
   },
   {
-    to: "/team",
-    label: "Team",
-    position: "right",
+    to: "https://github.com/apache/apisix/discussions";,
+    label: "Discussions"
   },
   {
     label: "Resources",
     position: "right",
     items: [
       {
-        to: "/docs/general/community",
-        label: "Community"
+        to: "/showcase",
+        label: "Showcase"
       },
       {
         to: "/plugins",
         label: "Plugin Hub",
       },
       {
-        to: "/releases",
-        label: "Releases",
+        to: "/docs/general/community",
+        label: "Community"
+      },
+      {
+        to: "/contribute",
+        label: "Contribute"
+      },
+      {
+        to: "/team",
+        label: "Team"
       },
       {
         to: "/help",
@@ -102,16 +87,6 @@ module.exports = [
     ]
   },
   {
-    to: "/showcase",
-    label: "Showcase",
-    position: "right",
-  },
-  {
-    to: "/contribute",
-    label: "Contribute",
-    position: "right",
-  },
-  {
     type: "localeDropdown",
     position: "right",
   },
diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js
index dfbab64..c00d8d8 100644
--- a/website/docusaurus.config.js
+++ b/website/docusaurus.config.js
@@ -108,14 +108,6 @@ module.exports = {
     [
       "@docusaurus/plugin-content-blog",
       {
-        id: "releases",
-        routeBasePath: "releases",
-        path: "releases",
-      },
-    ],
-    [
-      "@docusaurus/plugin-content-blog",
-      {
         id: "articles",
         routeBasePath: "articles",
         path: "articles",

Reply via email to