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

zihaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler-website.git


The following commit(s) were added to refs/heads/master by this push:
     new 9a2fb07435 [Fix] fix website search (#964)
9a2fb07435 is described below

commit 9a2fb07435c703c6458f38cabd44ff9f6d9b476f
Author: zuo <[email protected]>
AuthorDate: Wed Jul 17 09:18:42 2024 +0800

    [Fix] fix website search (#964)
    
    * [Fix-14108] fix English website can not search
---
 public/worker/db.js                     |  1 +
 scripts/generate_docs.js                |  2 +-
 src/views/Documentation/SearchModal.jsx |  4 ++--
 src/views/Documentation/helpers.js      | 15 +++++++++++++++
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/public/worker/db.js b/public/worker/db.js
index 86237f05f1..07f73f6a97 100644
--- a/public/worker/db.js
+++ b/public/worker/db.js
@@ -214,6 +214,7 @@ const searchDocVersion = async (value, version) => {
         title: replaceStr(item.title, value, 80, titleI),
         desc: replaceStr(item.content, value, 100, contentI),
         location: item.location,
+        link: item.link,
       });
     }
   }
diff --git a/scripts/generate_docs.js b/scripts/generate_docs.js
index 9accdd7455..5129afdf32 100644
--- a/scripts/generate_docs.js
+++ b/scripts/generate_docs.js
@@ -216,7 +216,7 @@ const wirteVersion = () => {
 };
 
 const wirteSearchDocData = () => {
-  [("en-us", "zh-cn")].forEach((lang) => {
+  ["en-us", "zh-cn"].forEach((lang) => {
     const targetSearchPath = `${BASE}/public/data/doc/${lang}.json`;
     fs.ensureFileSync(targetSearchPath);
     fs.writeFileSync(
diff --git a/src/views/Documentation/SearchModal.jsx 
b/src/views/Documentation/SearchModal.jsx
index 1edcb2f68e..67648404d6 100644
--- a/src/views/Documentation/SearchModal.jsx
+++ b/src/views/Documentation/SearchModal.jsx
@@ -1,7 +1,7 @@
 import { memo, useState, useEffect } from "react";
 import { Modal, Input, Button, Breadcrumb, Empty, Spin } from "antd";
 import { useParams } from "react-router-dom";
-import { getLinkFromLocation } from "./helpers";
+import { getSearchItemLinkFromLocation } from "./helpers";
 
 const SearchModal = ({ open, list, value, onClose, loading, handleSearch }) => 
{
   const params = useParams();
@@ -62,7 +62,7 @@ const SearchModal = ({ open, list, value, onClose, loading, 
handleSearch }) => {
                       <a
                         href={`/${params.locale}/docs/${
                           params.version
-                        }${getLinkFromLocation(item.location, i)}`}
+                        }${getSearchItemLinkFromLocation(item, i)}`}
                       >
                         {slip}
                       </a>
diff --git a/src/views/Documentation/helpers.js 
b/src/views/Documentation/helpers.js
index 9fbc5567eb..12808a63f2 100644
--- a/src/views/Documentation/helpers.js
+++ b/src/views/Documentation/helpers.js
@@ -29,3 +29,18 @@ export const getLinkFromLocation = (location, index) => {
   });
   return link;
 };
+
+export const getSearchItemLinkFromLocation = (searchItem, index) => {
+  const location = searchItem.location;
+  if (!location || !Array.isArray(location)) return "";
+  let link = "";
+  location.some((item, i) => {
+    if (i <= index) {
+      link += "/" + formatName(item);
+    }
+    if (i !== location.length - 1) link += "_menu";
+    if (i === location.length - 1) link = searchItem.link;
+    return i >= index;
+  });
+  return link;
+};

Reply via email to