You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2022/04/14 02:21:26 UTC

[apisix-website] branch master updated: fix: undefind in chinese doc drop-down (#1029)

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 435533382fe fix: undefind in chinese doc drop-down (#1029)
435533382fe is described below

commit 435533382fea7a2257cc18130f4b98091e7d45cd
Author: SkyeYoung <is...@outlook.com>
AuthorDate: Thu Apr 14 10:21:20 2022 +0800

    fix: undefind in chinese doc drop-down (#1029)
---
 website/src/theme/DocPage/index.tsx | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/website/src/theme/DocPage/index.tsx b/website/src/theme/DocPage/index.tsx
index 2e9fc49c464..298f1226527 100644
--- a/website/src/theme/DocPage/index.tsx
+++ b/website/src/theme/DocPage/index.tsx
@@ -47,6 +47,8 @@ const navbarLinkMap = {
   'python-plugin-runner': 'Apache APISIX® Python Plugin Runner',
 };
 
+const navbarLinkKeys = Object.keys(navbarLinkMap);
+
 const DocPageContent = ({
   currentDocRoute,
   versionMetadata,
@@ -64,13 +66,10 @@ const DocPageContent = ({
   useEffect(() => {
     const childrenCount = document.querySelector('.navbar__items--right').childElementCount;
     const el = document.querySelector('.navbar__items--right').childNodes[childrenCount - 2] as HTMLDivElement;
-    if (window.innerWidth > 745) {
-      el.style.display = 'block';
-    } else {
-      el.style.display = 'none';
-    }
+    el.style.display = window.innerWidth > 745 ? 'block' : 'none';
 
-    const currentPage = currentDocRoute.path.split('/')[2] || '';
+    const pathArr = currentDocRoute.path.split('/').slice(2, 4);
+    const currentPage = pathArr.reduce((res, cur) => (navbarLinkKeys.includes(cur) ? cur : res), '');
     const navbarLink = document.querySelectorAll('.navbar__link')[0] as HTMLAnchorElement;
     navbarLink.innerText = navbarLinkMap[currentPage];