|
@ -26,9 +26,7 @@ interface Articles { |
|
|
en: Article[]; |
|
|
en: Article[]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
interface Authors { |
|
|
type Authors = Author[]; |
|
|
[name: string]: Author; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface ArticleListProps { |
|
|
interface ArticleListProps { |
|
|
name: React.ReactNode; |
|
|
name: React.ReactNode; |
|
@ -36,16 +34,16 @@ interface ArticleListProps { |
|
|
authors: Authors; |
|
|
authors: Authors; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const ArticleList: React.FC<ArticleListProps> = ({ name, data, authors = {} }) => ( |
|
|
const ArticleList: React.FC<ArticleListProps> = ({ name, data, authors = [] }) => ( |
|
|
<td> |
|
|
<td> |
|
|
<h4>{name}</h4> |
|
|
<h4>{name}</h4> |
|
|
<ul className="article-list"> |
|
|
<ul className="article-list"> |
|
|
{data.map((article, index) => { |
|
|
{data.map((article, index) => { |
|
|
const author = authors[article.author] || {}; |
|
|
const author = authors.find(auth => auth.name === article.author); |
|
|
return ( |
|
|
return ( |
|
|
<li key={index}> |
|
|
<li key={index}> |
|
|
<a href={author.href} target="_blank" rel="noreferrer"> |
|
|
<a href={author?.href} target="_blank" rel="noreferrer"> |
|
|
<Avatar size="small" src={author.avatar} /> |
|
|
<Avatar size="small" src={author?.avatar} /> |
|
|
</a> |
|
|
</a> |
|
|
<Divider type="vertical" /> |
|
|
<Divider type="vertical" /> |
|
|
<a href={article.href} target="_blank" rel="noreferrer"> |
|
|
<a href={article.href} target="_blank" rel="noreferrer"> |
|
@ -61,7 +59,7 @@ const ArticleList: React.FC<ArticleListProps> = ({ name, data, authors = {} }) = |
|
|
export default () => { |
|
|
export default () => { |
|
|
const { locale } = useIntl(); |
|
|
const { locale } = useIntl(); |
|
|
const isZhCN = locale === 'zh-CN'; |
|
|
const isZhCN = locale === 'zh-CN'; |
|
|
const [{ articles = { cn: [], en: [] }, authors = {} }, loading] = |
|
|
const [{ articles = { cn: [], en: [] }, authors = [] }, loading] = |
|
|
useSiteData<{ articles: Articles; authors: Authors }>(); |
|
|
useSiteData<{ articles: Articles; authors: Authors }>(); |
|
|
|
|
|
|
|
|
// ========================== Data ==========================
|
|
|
// ========================== Data ==========================
|
|
|