Просмотр исходного кода

remove em tag from page path to be displayed

yuto-oweseek 4 лет назад
Родитель
Сommit
a3469357db
1 измененных файлов с 12 добавлено и 1 удалено
  1. 12 1
      packages/app/src/components/PagePathHierarchicalLink.jsx

+ 12 - 1
packages/app/src/components/PagePathHierarchicalLink.jsx

@@ -5,6 +5,9 @@ import urljoin from 'url-join';
 
 import LinkedPagePath from '../models/linked-page-path';
 
+const HIGHLIGHT_START_TAG = '<em class="highlighted-keyword">';
+const HIGHLIGHT_END_TAG = '</em>';
+
 
 const PagePathHierarchicalLink = (props) => {
   const {
@@ -37,11 +40,19 @@ const PagePathHierarchicalLink = (props) => {
       );
   }
 
+  const removeHighlightTag = (href) => {
+
+    if (href.includes(HIGHLIGHT_START_TAG) && href.includes(HIGHLIGHT_END_TAG)) {
+      return href.replaceAll(HIGHLIGHT_START_TAG, '').replaceAll(HIGHLIGHT_END_TAG, '');
+    }
+    return href;
+  };
+
   const isParentExists = linkedPagePath.parent != null;
   const isParentRoot = linkedPagePath.parent?.isRoot;
   const isSeparatorRequired = isParentExists && !isParentRoot;
 
-  const href = encodeURI(urljoin(basePath || '/', linkedPagePath.href));
+  const href = encodeURI(urljoin(basePath || '/', removeHighlightTag(linkedPagePath.href)));
 
   // eslint-disable-next-line react/prop-types
   const RootElm = ({ children }) => {