You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ti...@apache.org on 2023/05/25 03:29:58 UTC

[pulsar-site] branch main updated: build: Add operation in text for REST API injections (#583)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 85564cdfbc7 build: Add operation in text for REST API injections (#583)
85564cdfbc7 is described below

commit 85564cdfbc76d404f78ff033284cd913259b0ef9
Author: sunheyi <50...@users.noreply.github.com>
AuthorDate: Thu May 25 11:29:53 2023 +0800

    build: Add operation in text for REST API injections (#583)
    
    Co-authored-by: tison <wa...@gmail.com>
---
 docusaurus.config.js | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/docusaurus.config.js b/docusaurus.config.js
index 38d33d35539..bb15ba16c42 100644
--- a/docusaurus.config.js
+++ b/docusaurus.config.js
@@ -89,34 +89,37 @@ const injectLinkParse = ([, prefix, , name, path]) => {
 
 const injectLinkParseForEndpoint = ([, info]) => {
     let [method, path, suffix] = info.split("|");
+
     if (!suffix) {
-        suffix = path;
+        suffix = "";
     }
 
     let restPath = path.split("/");
     const restApiVersion = restPath[2];
     const restApiType = restPath[3];
-    let restBaseUrl = restApiUrl;
-    if (restApiType == "functions") {
-        restBaseUrl = functionsApiUrl;
-    } else if (restApiType == "source") {
-        restBaseUrl = sourceApiUrl;
-    } else if (restApiType == "sink") {
-        restBaseUrl = sinkApiUrl;
-    } else if (restApiType == "packages") {
-        restBaseUrl = packagesApiUrl;
-    } else if (restApiType == "transactions") {
-        restBaseUrl = transactionsApiUrl;
-    } else if (restApiType == "lookup") {
-        restBaseUrl = lookupApiUrl;
-    }
-    let restUrl = "";
+    const restBaseUrl = {
+      functions: functionsApiUrl,
+      source: sourceApiUrl,
+      sink: sinkApiUrl,
+      packages: packagesApiUrl,
+      transactions: transactionsApiUrl,
+      lookup: lookupApiUrl
+    }[restApiType] || restApiUrl;
+
+    let restUrl;
     if (suffix.indexOf("?version=") >= 0) {
         const suffixAndVersion = suffix.split("?version=")
         restUrl = "version=" + suffixAndVersion[1] + "&apiversion=" + restApiVersion + "#" + suffixAndVersion[0];
+        if (suffixAndVersion[0].startsWith("operation/")) {
+          path += suffixAndVersion[0].slice("operation".length)
+        }
     } else {
         restUrl = "version=master&apiversion=" + restApiVersion + "#" + suffix;
+        if (suffix[0].startsWith("operation/")) {
+          path += suffix[0].slice("operation".length)
+        }
     }
+
     return {
         text: method + " " + path,
         link: restBaseUrl + "?" + restUrl,