From c5dfd61cf57c4851a22d6094c24c6be1f23966e4 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 15 Jun 2021 19:15:41 +0800 Subject: [PATCH] docs: fix articles empty bug --- .../template/Resources/Articles/index.tsx | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/site/theme/template/Resources/Articles/index.tsx b/site/theme/template/Resources/Articles/index.tsx index c209f8dccf..6f89778ef5 100644 --- a/site/theme/template/Resources/Articles/index.tsx +++ b/site/theme/template/Resources/Articles/index.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import moment from 'moment'; import { FormattedMessage, useIntl } from 'react-intl'; -import { Tabs, Skeleton, Avatar, Divider } from 'antd'; +import { Tabs, Skeleton, Avatar, Divider, Empty } from 'antd'; import { useSiteData } from '../../Home/util'; import './index.less'; @@ -34,24 +34,28 @@ interface ArticleListProps { authors: Authors; } -const ArticleList: React.FC = ({ name, data, authors = [] }) => ( +const ArticleList: React.FC = ({ name, data = [], authors = [] }) => (

{name}

    - {data.map((article, index) => { - const author = authors.find(auth => auth.name === article.author); - return ( -
  • - - - - - - {article.title} - -
  • - ); - })} + {data.length === 0 ? ( + + ) : ( + data.map((article, index) => { + const author = authors.find(auth => auth.name === article.author); + return ( +
  • + + + + + + {article.title} + +
  • + ); + }) + )}
);