mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
docs: Use cdn to speed up (#30973)
This commit is contained in:
parent
fe35f4166d
commit
ce1aad03da
@ -6,7 +6,7 @@ import './MorePage.less';
|
||||
|
||||
type SourceType = 'zhihu' | 'yuque';
|
||||
|
||||
type Icons = Record<SourceType, string>;
|
||||
type Icons = { name: string; href: string }[];
|
||||
|
||||
interface MoreProps {
|
||||
title: string;
|
||||
@ -42,7 +42,9 @@ const MoreCard = ({ title, description, date, img, source, href, icons, loading
|
||||
<div>
|
||||
{date}
|
||||
<span className="more-card-source">
|
||||
{icons ? <img src={icons[source]} alt={source} /> : null}
|
||||
{icons ? (
|
||||
<img src={icons.find(icon => icon.name === source)?.href} alt={source} />
|
||||
) : null}
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
|
@ -22,7 +22,7 @@ export function useSiteData<T>(): [T, boolean] {
|
||||
React.useEffect(() => {
|
||||
if (Object.keys(data).length === 0 && typeof fetch !== 'undefined') {
|
||||
setLoading(true);
|
||||
fetch(`https://raw.githubusercontent.com/ant-design/website-data/main/db.json`)
|
||||
fetch(`https://render.alipay.com/p/h5data/antd4-config_website-h5data.json`)
|
||||
.then(res => res.json())
|
||||
.then(result => {
|
||||
setData(result);
|
||||
|
@ -26,9 +26,7 @@ interface Articles {
|
||||
en: Article[];
|
||||
}
|
||||
|
||||
interface Authors {
|
||||
[name: string]: Author;
|
||||
}
|
||||
type Authors = Author[];
|
||||
|
||||
interface ArticleListProps {
|
||||
name: React.ReactNode;
|
||||
@ -36,16 +34,16 @@ interface ArticleListProps {
|
||||
authors: Authors;
|
||||
}
|
||||
|
||||
const ArticleList: React.FC<ArticleListProps> = ({ name, data, authors = {} }) => (
|
||||
const ArticleList: React.FC<ArticleListProps> = ({ name, data, authors = [] }) => (
|
||||
<td>
|
||||
<h4>{name}</h4>
|
||||
<ul className="article-list">
|
||||
{data.map((article, index) => {
|
||||
const author = authors[article.author] || {};
|
||||
const author = authors.find(auth => auth.name === article.author);
|
||||
return (
|
||||
<li key={index}>
|
||||
<a href={author.href} target="_blank" rel="noreferrer">
|
||||
<Avatar size="small" src={author.avatar} />
|
||||
<a href={author?.href} target="_blank" rel="noreferrer">
|
||||
<Avatar size="small" src={author?.avatar} />
|
||||
</a>
|
||||
<Divider type="vertical" />
|
||||
<a href={article.href} target="_blank" rel="noreferrer">
|
||||
@ -61,7 +59,7 @@ const ArticleList: React.FC<ArticleListProps> = ({ name, data, authors = {} }) =
|
||||
export default () => {
|
||||
const { locale } = useIntl();
|
||||
const isZhCN = locale === 'zh-CN';
|
||||
const [{ articles = { cn: [], en: [] }, authors = {} }, loading] =
|
||||
const [{ articles = { cn: [], en: [] }, authors = [] }, loading] =
|
||||
useSiteData<{ articles: Articles; authors: Authors }>();
|
||||
|
||||
// ========================== Data ==========================
|
||||
|
Loading…
Reference in New Issue
Block a user