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/09/19 03:08:48 UTC

[pulsar-site] branch fix-rest-api-page-crash created (now 8a5be86a423)

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

urfree pushed a change to branch fix-rest-api-page-crash
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git


      at 8a5be86a423 fix rest api page crash

This branch includes the following new commits:

     new 8a5be86a423 fix rest api page crash

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[pulsar-site] 01/01: fix rest api page crash

Posted by ur...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

urfree pushed a commit to branch fix-rest-api-page-crash
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git

commit 8a5be86a4231fbbf0b7c9910f2d0b10d975bc315
Author: Li Li <ur...@apache.org>
AuthorDate: Mon Sep 19 11:08:38 2022 +0800

    fix rest api page crash
    
    Signed-off-by: Li Li <ur...@apache.org>
---
 site2/website-next/package.json              |  2 +-
 site2/website-next/src/components/CLI.js     |  2 +-
 site2/website-next/src/components/RestApi.js |  2 +-
 site2/website-next/src/utils/index.js        | 14 ++++++++++----
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/site2/website-next/package.json b/site2/website-next/package.json
index 0f7fb9942cd..544cf0c01ca 100644
--- a/site2/website-next/package.json
+++ b/site2/website-next/package.json
@@ -9,7 +9,7 @@
     "build": "NODE_OPTIONS=--max_old_space_size=16000 docusaurus build",
     "build:all:split": "BUILD_ALL_VERSION=1 ./scripts/split-version-build.sh",
     "sync:docs": "./scripts/sync-docs.sh",
-    "preview": "npm run build && sh scripts/docker.sh",
+    "preview": "docusaurus build --locale en && docker-compose up",
     "swizzle": "docusaurus swizzle",
     "deploy": "docusaurus deploy",
     "clear": "docusaurus clear",
diff --git a/site2/website-next/src/components/CLI.js b/site2/website-next/src/components/CLI.js
index 1042dd9feb0..5d568c92525 100644
--- a/site2/website-next/src/components/CLI.js
+++ b/site2/website-next/src/components/CLI.js
@@ -1,7 +1,7 @@
 const React = require("react");
 import Layout from "@theme/Layout";
 const versionList = require("../../versions.json");
-import { setVersion, getVersion, getApiVersion } from "../utils/index.js";
+import { getVersion } from "../utils/index.js";
 
 function parseVersion() {}
 
diff --git a/site2/website-next/src/components/RestApi.js b/site2/website-next/src/components/RestApi.js
index 581c884c53f..ad648344f87 100644
--- a/site2/website-next/src/components/RestApi.js
+++ b/site2/website-next/src/components/RestApi.js
@@ -1,6 +1,6 @@
 const React = require("react");
 import Layout from "@theme/Layout";
-import { setVersion, getVersion, getApiVersion } from "../utils/index.js";
+import { getVersion, getApiVersion } from "../utils/index.js";
 
 function parseVersion(pathName) {
   let swagger = "swagger";
diff --git a/site2/website-next/src/utils/index.js b/site2/website-next/src/utils/index.js
index 4ef5b937d03..9d9c9b35fe1 100644
--- a/site2/website-next/src/utils/index.js
+++ b/site2/website-next/src/utils/index.js
@@ -54,10 +54,15 @@ export function setVersion(version) {
 }
 
 export function getVersion() {
-  if (!getCache()) {
-    return latestStableVersion;
+  // if (!getCache()) {
+  //   return latestStableVersion;
+  // }
+  // return getCache().getItem("version") || latestStableVersion;
+  //version=2.10.1
+  if (/version=(\d+\.?\x?)+/.test(location.href)) {
+    return location.href.match(/version=(\d+\.?\x?)+/)[0];
   }
-  return getCache().getItem("version") || latestStableVersion;
+  return "master";
 }
 
 export function getApiVersion(anchor) {
@@ -66,9 +71,10 @@ export function getApiVersion(anchor) {
   let _restApiVs = {};
   let _vsGroups = {};
   for (let [key, val] of Object.entries(restApiVersions)) {
-    if (key == 'master' || compareVersions.compare(key, "2.8.0", "<")) {
+    if (key == "master" || compareVersions.compare(key, "2.8.0", "<")) {
       _restApiVs[key] = val;
     } else {
+      _restApiVs[key] = val;
       let [one, two] = key.split(".");
       let _tKey = one + "." + two + ".x";
       _vsGroups[_tKey] = [...(_vsGroups[_tKey] || []), key];