mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 07:56:28 +08:00
site: fix site error (#39138)
This commit is contained in:
parent
a7f94d5457
commit
ada192f3a0
@ -44,7 +44,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
|
||||
|
||||
return (
|
||||
sidebarItems?.reduce<Exclude<MenuProps['items'], undefined>>((result, group) => {
|
||||
if (group.title) {
|
||||
if (group?.title) {
|
||||
// 设计文档特殊处理二级分组
|
||||
if (pathname.startsWith('/docs/spec')) {
|
||||
const childrenGroup = group.children.reduce<
|
||||
@ -63,7 +63,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
|
||||
label: (
|
||||
<Link to={`${item.link}${search}`}>
|
||||
{before}
|
||||
{item.title}
|
||||
{item?.title}
|
||||
{after}
|
||||
</Link>
|
||||
),
|
||||
@ -80,7 +80,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
|
||||
label: (
|
||||
<Link to={`${item.link}${search}`}>
|
||||
{before}
|
||||
{item.title}
|
||||
{item?.title}
|
||||
{after}
|
||||
</Link>
|
||||
),
|
||||
@ -90,20 +90,20 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
|
||||
}
|
||||
});
|
||||
result.push({
|
||||
label: group.title,
|
||||
key: group.title,
|
||||
label: group?.title,
|
||||
key: group?.title,
|
||||
children: childItems,
|
||||
});
|
||||
} else {
|
||||
result.push({
|
||||
type: 'group',
|
||||
label: group.title,
|
||||
key: group.title,
|
||||
label: group?.title,
|
||||
key: group?.title,
|
||||
children: group.children?.map((item) => ({
|
||||
label: (
|
||||
<Link to={`${item.link}${search}`}>
|
||||
{before}
|
||||
<span key="english">{item.title}</span>
|
||||
<span key="english">{item?.title}</span>
|
||||
<span className="chinese" key="chinese">
|
||||
{(item.frontmatter as any).subtitle}
|
||||
</span>
|
||||
@ -120,7 +120,7 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] =>
|
||||
label: (
|
||||
<Link to={`${item.link}${search}`}>
|
||||
{before}
|
||||
{item.title}
|
||||
{item?.title}
|
||||
{after}
|
||||
</Link>
|
||||
),
|
||||
|
@ -58,8 +58,8 @@ export default function BannerRecommends({ extras = [], icons = [] }: BannerReco
|
||||
}
|
||||
const icon = icons.find((i) => i.name === extra.source);
|
||||
return (
|
||||
<a key={extra.title} href={extra.href} target="_blank" css={style.card} rel="noreferrer">
|
||||
<Typography.Title level={5}>{extra.title}</Typography.Title>
|
||||
<a key={extra?.title} href={extra.href} target="_blank" css={style.card} rel="noreferrer">
|
||||
<Typography.Title level={5}>{extra?.title}</Typography.Title>
|
||||
<Typography.Paragraph type="secondary" style={{ flex: 'auto' }}>
|
||||
{extra.description}
|
||||
</Typography.Paragraph>
|
||||
|
@ -91,7 +91,7 @@ export default function Recommends({ recommendations = [] }: RecommendsProps) {
|
||||
{data ? (
|
||||
<div css={style.card} style={{ backgroundImage: `url(${data.img})` }}>
|
||||
<div className="intro">
|
||||
<Typography.Title level={4}>{data.title}</Typography.Title>
|
||||
<Typography.Title level={4}>{data?.title}</Typography.Title>
|
||||
<Typography.Paragraph>{data.description}</Typography.Paragraph>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -97,11 +97,11 @@ const Overview: React.FC = () => {
|
||||
const groups = useMemo<{ title: string; children: Component[] }[]>(
|
||||
() =>
|
||||
data
|
||||
.filter((item) => item.title)
|
||||
.filter((item) => item?.title)
|
||||
.map<{ title: string; children: Component[] }>((item) => ({
|
||||
title: item.title!,
|
||||
title: item?.title,
|
||||
children: item.children.map((child) => ({
|
||||
title: child.frontmatter.title,
|
||||
title: child.frontmatter?.title,
|
||||
subtitle: child.frontmatter.subtitle,
|
||||
cover: child.frontmatter.cover,
|
||||
link: child.link,
|
||||
@ -136,19 +136,19 @@ const Overview: React.FC = () => {
|
||||
/>
|
||||
<Divider />
|
||||
{groups
|
||||
.filter((i) => i.title)
|
||||
.filter((i) => i?.title)
|
||||
.map((group) => {
|
||||
const components = group?.children?.filter(
|
||||
(component) =>
|
||||
!search.trim() ||
|
||||
component.title.toLowerCase().includes(search.trim().toLowerCase()) ||
|
||||
component?.title?.toLowerCase()?.includes(search.trim().toLowerCase()) ||
|
||||
(component?.subtitle || '').toLowerCase().includes(search.trim().toLowerCase()),
|
||||
);
|
||||
return components?.length ? (
|
||||
<div key={group.title} css={style.componentsOverview}>
|
||||
<div key={group?.title} css={style.componentsOverview}>
|
||||
<Title level={2} css={style.componentsOverviewGroupTitle}>
|
||||
<Space align="center">
|
||||
<span style={{ fontSize: 24 }}>{group.title}</span>
|
||||
<span style={{ fontSize: 24 }}>{group?.title}</span>
|
||||
<Tag style={{ display: 'block' }}>{components.length}</Tag>
|
||||
</Space>
|
||||
</Title>
|
||||
@ -160,7 +160,7 @@ const Overview: React.FC = () => {
|
||||
const ComponentLink = !url.startsWith('http') ? Link : 'a';
|
||||
|
||||
return (
|
||||
<Col xs={24} sm={12} lg={8} xl={6} key={component.title}>
|
||||
<Col xs={24} sm={12} lg={8} xl={6} key={component?.title}>
|
||||
<ComponentLink to={url} href={url} onClick={() => onClickCard(url)}>
|
||||
<Card
|
||||
bodyStyle={{
|
||||
@ -172,12 +172,12 @@ const Overview: React.FC = () => {
|
||||
css={style.componentsOverviewCard}
|
||||
title={
|
||||
<div css={style.componentsOverviewTitle}>
|
||||
{component.title} {component.subtitle}
|
||||
{component?.title} {component.subtitle}
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div css={style.componentsOverviewImg}>
|
||||
<img src={component.cover} alt={component.title} />
|
||||
<img src={component.cover} alt={component?.title} />
|
||||
</div>
|
||||
</Card>
|
||||
</ComponentLink>
|
||||
|
@ -158,7 +158,7 @@ class Demo extends React.Component {
|
||||
expand: codeExpand,
|
||||
'code-box-debug': meta.debug,
|
||||
});
|
||||
const localizedTitle = meta.title[locale] || meta.title;
|
||||
const localizedTitle = meta?.title[locale] || meta?.title;
|
||||
const localizeIntro = content[locale] || content;
|
||||
const introChildren = <div dangerouslySetInnerHTML={{ __html: localizeIntro }} />;
|
||||
|
||||
|
@ -84,7 +84,7 @@ const ArticleList: React.FC<ArticleListProps> = ({ name, data = [], authors = []
|
||||
</a>
|
||||
<Divider type="vertical" />
|
||||
<a href={article.href} target="_blank" rel="noreferrer">
|
||||
{article.title}
|
||||
{article?.title}
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
|
@ -94,7 +94,7 @@ const ResourceCard: React.FC<ResourceCardProps> = ({ resource }) => {
|
||||
style={coverColor ? { backgroundColor: coverColor } : {}}
|
||||
/>
|
||||
{official && <div css={styles.badge}>Official</div>}
|
||||
<p css={styles.title}>{title}</p>
|
||||
<p css={styles?.title}>{title}</p>
|
||||
<p css={styles.description}>{description}</p>
|
||||
</a>
|
||||
</Col>
|
||||
@ -108,7 +108,7 @@ export type ResourceCardsProps = {
|
||||
const ResourceCards: React.FC<ResourceCardsProps> = ({ resources }) => (
|
||||
<Row style={{ margin: '-12px -12px 0 -12px' }}>
|
||||
{resources.map((item) => (
|
||||
<ResourceCard resource={item} key={item.title} />
|
||||
<ResourceCard resource={item} key={item?.title} />
|
||||
))}
|
||||
</Row>
|
||||
);
|
||||
|
@ -5,7 +5,9 @@ const CommonHelmet = () => {
|
||||
const meta = useRouteMeta();
|
||||
|
||||
const [title, description] = useMemo(() => {
|
||||
const helmetTitle = `${meta.frontmatter.subtitle || ''} ${meta.frontmatter.title} - Ant Design`;
|
||||
const helmetTitle = `${meta.frontmatter.subtitle || ''} ${
|
||||
meta.frontmatter?.title
|
||||
} - Ant Design`;
|
||||
const helmetDescription = meta.frontmatter.description;
|
||||
return [helmetTitle, helmetDescription];
|
||||
}, [meta]);
|
||||
|
@ -143,13 +143,13 @@ const DocLayout: React.FC = () => {
|
||||
data-direction={direction}
|
||||
className={classNames({ [`rtl`]: direction === 'rtl' })}
|
||||
/>
|
||||
<title>{locale.title}</title>
|
||||
<title>{locale?.title}</title>
|
||||
<link
|
||||
sizes="144x144"
|
||||
href="https://gw.alipayobjects.com/zos/antfincdn/UmVnt3t4T0/antd.png"
|
||||
/>
|
||||
<meta name="description" content={locale.description} />
|
||||
<meta property="og:title" content={locale.title} />
|
||||
<meta property="og:title" content={locale?.title} />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta
|
||||
property="og:image"
|
||||
|
@ -122,7 +122,7 @@ const ResourceLayout: FC<ResourceLayoutProps> = ({ children }) => {
|
||||
<AffixTabs />
|
||||
<div css={styles.banner}>
|
||||
<Typography.Title style={{ fontSize: 30 }}>
|
||||
{meta.frontmatter.title}
|
||||
{meta.frontmatter?.title}
|
||||
<EditButton
|
||||
title={<FormattedMessage id="app.content.edit-page" />}
|
||||
filename={meta.frontmatter.filename}
|
||||
|
@ -149,7 +149,7 @@ const Content: React.FC<{ children: ReactNode }> = ({ children }) => {
|
||||
<section css={styles.tocWrapper} className={classNames({ rtl: isRTL })}>
|
||||
<Anchor css={styles.toc} affix={false} showInkInFixed>
|
||||
{anchorItems.map((item) => (
|
||||
<Anchor.Link href={`#${item.id}`} title={item.title} key={item.id}>
|
||||
<Anchor.Link href={`#${item.id}`} title={item?.title} key={item.id}>
|
||||
{item.children
|
||||
?.filter((child) => showDebug || !debugDemos.includes(child.id))
|
||||
.map((child) => (
|
||||
@ -159,7 +159,7 @@ const Content: React.FC<{ children: ReactNode }> = ({ children }) => {
|
||||
<span
|
||||
className={classNames(debugDemos.includes(child.id) && 'toc-debug')}
|
||||
>
|
||||
{child.title}
|
||||
{child?.title}
|
||||
</span>
|
||||
}
|
||||
key={child.id}
|
||||
@ -172,7 +172,7 @@ const Content: React.FC<{ children: ReactNode }> = ({ children }) => {
|
||||
</Affix>
|
||||
<article css={styles.articleWrapper} className={classNames({ rtl: isRTL })}>
|
||||
<Typography.Title style={{ fontSize: 30 }}>
|
||||
{meta.frontmatter.title}
|
||||
{meta.frontmatter?.title}
|
||||
{meta.frontmatter.subtitle && (
|
||||
<span style={{ marginLeft: 12 }}>{meta.frontmatter.subtitle}</span>
|
||||
)}
|
||||
|
@ -341,7 +341,7 @@ const Header: React.FC<HeaderProps> = (props) => {
|
||||
<Popover
|
||||
key="version"
|
||||
open={!!notify}
|
||||
title={locale.title}
|
||||
title={locale?.title}
|
||||
content={
|
||||
<Typography style={{ marginTop: token.marginXS }}>
|
||||
{lang === 'cn' ? (
|
||||
|
@ -41,7 +41,7 @@ export function getMenuItems(
|
||||
if (meta.type) {
|
||||
meta.type = meta.type[locale] || meta.type;
|
||||
}
|
||||
if (meta.title) {
|
||||
if (meta?.title) {
|
||||
meta.title = meta.title[locale] || meta.title;
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ export function getMenuItems(
|
||||
|
||||
// Component
|
||||
if (meta.category === 'Components' && meta.type) {
|
||||
let type = menuItems.find((i) => i.title === meta.type);
|
||||
let type = menuItems.find((i) => i?.title === meta.type);
|
||||
if (!type) {
|
||||
type = {
|
||||
type: 'type',
|
||||
@ -67,7 +67,7 @@ export function getMenuItems(
|
||||
return;
|
||||
}
|
||||
|
||||
let group = menuItems.find((i) => i.title === meta.category);
|
||||
let group = menuItems.find((i) => i?.title === meta.category);
|
||||
|
||||
if (!group) {
|
||||
group = {
|
||||
@ -82,7 +82,7 @@ export function getMenuItems(
|
||||
group.children = group.children || [];
|
||||
|
||||
if (meta.type) {
|
||||
let type = group.children.filter((i) => i.title === meta.type)[0];
|
||||
let type = group.children.filter((i) => i?.title === meta.type)[0];
|
||||
if (!type) {
|
||||
type = {
|
||||
type: 'type',
|
||||
|
Loading…
Reference in New Issue
Block a user