Parcourir la source

支持导航条路径

visuddhinanda il y a 2 ans
Parent
commit
ec2fc5521c
1 fichiers modifiés avec 20 ajouts et 0 suppressions
  1. 20 0
      dashboard/src/components/article/TypePali.tsx

+ 20 - 0
dashboard/src/components/article/TypePali.tsx

@@ -290,6 +290,26 @@ const TypePaliWidget = ({
             <Navigate
               type={type as ArticleType}
               articleId={articleId}
+              path={articleData?.path}
+              onPathChange={(key: string) => {
+                const node = articleData?.path?.find(
+                  (value) => value.title === key
+                );
+                if (node) {
+                  let newType = type;
+                  if (node.level === 0) {
+                    newType = "series";
+                  } else {
+                    newType = "chapter";
+                  }
+                  if (typeof onArticleChange !== "undefined") {
+                    const newArticle = node.key
+                      ? node.key
+                      : `${node.book}-${node.paragraph}`;
+                    onArticleChange(newType, newArticle, "self");
+                  }
+                }
+              }}
               onChange={(
                 event: React.MouseEvent<HTMLElement, MouseEvent>,
                 newId: string