mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-08 01:53:34 +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 SourceType = 'zhihu' | 'yuque';
|
||||||
|
|
||||||
type Icons = Record<SourceType, string>;
|
type Icons = { name: string; href: string }[];
|
||||||
|
|
||||||
interface MoreProps {
|
interface MoreProps {
|
||||||
title: string;
|
title: string;
|
||||||
@ -42,7 +42,9 @@ const MoreCard = ({ title, description, date, img, source, href, icons, loading
|
|||||||
<div>
|
<div>
|
||||||
{date}
|
{date}
|
||||||
<span className="more-card-source">
|
<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>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
@ -22,7 +22,7 @@ export function useSiteData<T>(): [T, boolean] {
|
|||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (Object.keys(data).length === 0 && typeof fetch !== 'undefined') {
|
if (Object.keys(data).length === 0 && typeof fetch !== 'undefined') {
|
||||||
setLoading(true);
|
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(res => res.json())
|
||||||
.then(result => {
|
.then(result => {
|
||||||
setData(result);
|
setData(result);
|
||||||
|
@ -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 ==========================
|
||||||
|
Loading…
Reference in New Issue
Block a user