ソースを参照

add PaliChapterChannelList

visuddhinanda 3 年 前
コミット
e8aa95eaa6
1 ファイル変更32 行追加2 行削除
  1. 32 2
      dashboard/src/components/article/ArticleView.tsx

+ 32 - 2
dashboard/src/components/article/ArticleView.tsx

@@ -3,6 +3,8 @@ import { ReloadOutlined } from "@ant-design/icons";
 
 
 import MdView from "../template/MdView";
 import MdView from "../template/MdView";
 import TocPath, { ITocPathNode } from "../corpus/TocPath";
 import TocPath, { ITocPathNode } from "../corpus/TocPath";
+import PaliChapterChannelList from "../corpus/PaliChapterChannelList";
+import { ArticleType } from "./Article";
 
 
 const { Paragraph, Title, Text } = Typography;
 const { Paragraph, Title, Text } = Typography;
 
 
@@ -17,6 +19,8 @@ export interface IWidgetArticleData {
   created_at?: string;
   created_at?: string;
   updated_at?: string;
   updated_at?: string;
   channels?: string[];
   channels?: string[];
+  type?: ArticleType;
+  articleId?: string;
 }
 }
 
 
 const Widget = ({
 const Widget = ({
@@ -30,8 +34,33 @@ const Widget = ({
   created_at,
   created_at,
   updated_at,
   updated_at,
   channels,
   channels,
+  type,
+  articleId,
 }: IWidgetArticleData) => {
 }: IWidgetArticleData) => {
-  console.log("path", path);
+  let currChannelList = <></>;
+  switch (type) {
+    case "chapter":
+      const chapterProps = articleId?.split("_");
+      if (typeof chapterProps === "object" && chapterProps.length > 0) {
+        const para = chapterProps[0].split("-");
+        const channels =
+          chapterProps.length > 1 ? chapterProps.slice(1) : undefined;
+        if (typeof para === "object" && para.length > 1) {
+          currChannelList = (
+            <PaliChapterChannelList
+              para={{ book: parseInt(para[0]), para: parseInt(para[1]) }}
+              channelId={channels}
+              openTarget="_self"
+            />
+          );
+        }
+      }
+
+      break;
+
+    default:
+      break;
+  }
   return (
   return (
     <>
     <>
       <Button shape="round" size="small" icon={<ReloadOutlined />}>
       <Button shape="round" size="small" icon={<ReloadOutlined />}>
@@ -45,9 +74,10 @@ const Widget = ({
             dangerouslySetInnerHTML={{
             dangerouslySetInnerHTML={{
               __html: title ? title : "",
               __html: title ? title : "",
             }}
             }}
-          ></div>
+          />
         </Title>
         </Title>
         <Text type="secondary">{subTitle}</Text>
         <Text type="secondary">{subTitle}</Text>
+        {currChannelList}
         <Paragraph ellipsis={{ rows: 2, expandable: true, symbol: "more" }}>
         <Paragraph ellipsis={{ rows: 2, expandable: true, symbol: "more" }}>
           {summary}
           {summary}
         </Paragraph>
         </Paragraph>