You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ur...@apache.org on 2022/02/22 03:35:10 UTC

[pulsar-site] 01/05: feat: migrate about.md

This is an automated email from the ASF dual-hosted git repository.

urfree pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git

commit 14f91de37a4057c8599df61a7908b7806e1d39ee
Author: LiLi <ur...@apache.org>
AuthorDate: Tue Feb 22 11:14:45 2022 +0800

    feat: migrate about.md
    
    Signed-off-by: LiLi <ur...@apache.org>
---
 .../version-2.9.1 => docs}/about.md                |  2 +-
 site2/website-next/docusaurus.config.js            | 10 +--
 site2/website-next/migrate/migrate-version.js      | 75 ++++++++++++++++------
 site2/website-next/sidebars.json                   | 26 ++------
 site2/website-next/src/utils/index.js              |  2 +-
 .../versioned_docs/version-2.9.1/about.md          |  2 +-
 6 files changed, 67 insertions(+), 50 deletions(-)

diff --git a/site2/website-next/versioned_docs/version-2.9.1/about.md b/site2/website-next/docs/about.md
similarity index 97%
copy from site2/website-next/versioned_docs/version-2.9.1/about.md
copy to site2/website-next/docs/about.md
index df5bc36..e36f3c4 100644
--- a/site2/website-next/versioned_docs/version-2.9.1/about.md
+++ b/site2/website-next/docs/about.md
@@ -45,7 +45,7 @@ An equally passionate community can be found in the Pulsar Slack channel (https:
 
 ## Get Started Now
 <BlockLinks>
-    <BlockLink title="Pulsar Basics" url={docUrl("standalone")} />
+    <BlockLink title="Pulsar Basics" url={docUrl()} />
     <BlockLink title="Quickstart" url={docUrl("about")} />
     <BlockLink title="Ecosystem" url='/ecosystem/' />
 </BlockLinks>
diff --git a/site2/website-next/docusaurus.config.js b/site2/website-next/docusaurus.config.js
index c596c42..6951fa4 100644
--- a/site2/website-next/docusaurus.config.js
+++ b/site2/website-next/docusaurus.config.js
@@ -125,11 +125,11 @@ module.exports = {
               docId: "concepts-overview",
               label: "Pulsar Concepts",
             },
-            // {
-            //   type: "doc",
-            //   label: "Quickstart",
-            //   docId: "about",
-            // },
+            {
+              type: "doc",
+              label: "Quickstart",
+              docId: "about",
+            },
             {
               label: "Ecosystem",
               to: "ecosystem",
diff --git a/site2/website-next/migrate/migrate-version.js b/site2/website-next/migrate/migrate-version.js
index 8a6a84e..d63401c 100644
--- a/site2/website-next/migrate/migrate-version.js
+++ b/site2/website-next/migrate/migrate-version.js
@@ -8,12 +8,6 @@ const delDuplicate = require("./tool/del-duplicate");
 const CONST = require("./const");
 const { old, next } = CONST;
 
-function _log(msg) {
-  if (typeof require !== "undefined" && require.main === module) {
-    console.log(msg);
-  }
-}
-
 const migrate = (version) => {
   let version_full = "version-" + version;
   let src = `../../${old.baseDir}/versioned_docs/` + version_full;
@@ -35,24 +29,63 @@ const migrate = (version) => {
   let sidebar = fs.readFileSync(sidebar_file, "utf8");
   sidebar = JSON.parse(sidebar);
 
-  const _key = version == "next" ? "docs" : version_full + "-docs";
-  let chapterList = _.keys(sidebar[_key]);
+  // const _key = version == "next" ? "docs" : version_full + "-docs";
+  // let chapterList = _.keys(sidebar[_key]);
 
-  let migratedList = [];
-  for (let chapter of chapterList) {
-    migrateChapter(version, chapter, (docsId) => {
-      migratedList.push(docsId);
-    });
-  }
-  let leftMdList = leftMd(version, migratedList);
-  for (let mdfile of leftMdList) {
-    console.log(
-      "     [" + version + ":left:" + path.basename(mdfile) + "]migrate..."
+  // let migratedList = [];
+  // for (let chapter of chapterList) {
+  //   migrateChapter(version, chapter, (docsId) => {
+  //     migratedList.push(docsId);
+  //   });
+  // }
+  // let leftMdList = leftMd(version, migratedList);
+  // for (let mdfile of leftMdList) {
+  //   console.log(
+  //     "     [" + version + ":left:" + path.basename(mdfile) + "]migrate..."
+  //   );
+  //   let data = fixMd(fs.readFileSync(mdfile, "utf8"));
+  //   fs.writeFileSync(path.join(dest, path.basename(mdfile)), data);
+  // }
+  // delDuplicate(dest, version);
+
+  //copy about.md from next version dir
+  sidebar = fs.readFileSync(
+    path.join(__dirname, `../../${next.baseDir}/sidebars.json`),
+    "utf8"
+  );
+  sidebar = JSON.parse(sidebar);
+  let aboutDocPath = path.join(__dirname, `../../${next.docsDir}/about.md`);
+  let destSidebarPath = path.join(
+    __dirname,
+    `../../${next.baseDir}/versioned_sidebars/${version_full}-sidebars.json`
+  );
+  if (version == "next") {
+    destSidebarPath = path.join(
+      __dirname,
+      `../../${next.baseDir}/sidebars.json`
+    );
+  } else {
+    fs.writeFileSync(
+      path.join(dest, "about.md"),
+      fs.readFileSync(aboutDocPath, "utf8")
     );
-    let data = fixMd(fs.readFileSync(mdfile, "utf8"));
-    fs.writeFileSync(path.join(dest, path.basename(mdfile)), data);
   }
-  delDuplicate(dest, version);
+  let items = Object.values(sidebar)[0];
+  let aboutId = version == "next" ? "about" : `${version_full}/about`;
+  let _items = [
+    {
+      type: "doc",
+      id: aboutId,
+    },
+  ];
+  for (let item of items) {
+    if (item.type == "doc" && id == aboutId) {
+      continue;
+    }
+    _items.push(item);
+  }
+  sidebar[Object.keys(sidebar)[0]] = _items;
+  fs.writeFileSync(destSidebarPath, JSON.stringify(sidebar, null, 2), "utf8");
 };
 
 module.exports = migrate;
diff --git a/site2/website-next/sidebars.json b/site2/website-next/sidebars.json
index 55f6e30..8595156 100644
--- a/site2/website-next/sidebars.json
+++ b/site2/website-next/sidebars.json
@@ -3,11 +3,7 @@
     {
       "type": "category",
       "label": "Get Started",
-      "items": [
-        "standalone",
-        "standalone-docker",
-        "kubernetes-helm"
-      ]
+      "items": ["standalone", "standalone-docker", "kubernetes-helm"]
     },
     {
       "type": "category",
@@ -89,13 +85,7 @@
     {
       "type": "category",
       "label": "Transactions",
-      "items": [
-        "txn-why",
-        "txn-what",
-        "txn-how",
-        "txn-use",
-        "txn-monitor"
-      ]
+      "items": ["txn-why", "txn-what", "txn-how", "txn-use", "txn-monitor"]
     },
     {
       "type": "category",
@@ -156,9 +146,7 @@
     {
       "type": "category",
       "label": "Performance",
-      "items": [
-        "performance-pulsar-perf"
-      ]
+      "items": ["performance-pulsar-perf"]
     },
     {
       "type": "category",
@@ -193,11 +181,7 @@
     {
       "type": "category",
       "label": "Adaptors",
-      "items": [
-        "adaptors-kafka",
-        "adaptors-spark",
-        "adaptors-storm"
-      ]
+      "items": ["adaptors-kafka", "adaptors-spark", "adaptors-storm"]
     },
     {
       "type": "category",
@@ -233,4 +217,4 @@
       ]
     }
   ]
-}
\ No newline at end of file
+}
diff --git a/site2/website-next/src/utils/index.js b/site2/website-next/src/utils/index.js
index 82e58d3..6ea98bb 100644
--- a/site2/website-next/src/utils/index.js
+++ b/site2/website-next/src/utils/index.js
@@ -17,8 +17,8 @@ export function docUrl(doc, language, version) {
   // if (version == "" || version == "next") {
   return (
     siteConfig.baseUrl +
-    "docs/" +
     (language ? language + "/" : "") +
+    "docs/" +
     (version ? version + "/" : "") +
     (doc ? doc : "")
   );
diff --git a/site2/website-next/versioned_docs/version-2.9.1/about.md b/site2/website-next/versioned_docs/version-2.9.1/about.md
index df5bc36..e36f3c4 100644
--- a/site2/website-next/versioned_docs/version-2.9.1/about.md
+++ b/site2/website-next/versioned_docs/version-2.9.1/about.md
@@ -45,7 +45,7 @@ An equally passionate community can be found in the Pulsar Slack channel (https:
 
 ## Get Started Now
 <BlockLinks>
-    <BlockLink title="Pulsar Basics" url={docUrl("standalone")} />
+    <BlockLink title="Pulsar Basics" url={docUrl()} />
     <BlockLink title="Quickstart" url={docUrl("about")} />
     <BlockLink title="Ecosystem" url='/ecosystem/' />
 </BlockLinks>