mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
docs: fix site document title flash during page loading (#44631)
* fix: site document title rerender after dumi prerender * fix: comment & index page listener render * fix: define seperate layour for index page & seperate Helmet title + desc definition --------- Co-authored-by: afc163 <afc163@gmail.com>
This commit is contained in:
parent
fc2b4af8cf
commit
24ed2cf364
@ -8,10 +8,10 @@ import ConfigProvider from 'antd/es/config-provider';
|
||||
import useLocale from '../../../hooks/useLocale';
|
||||
import useLocation from '../../../hooks/useLocation';
|
||||
import GlobalStyles from '../../common/GlobalStyles';
|
||||
import Footer from '../../slots/Footer';
|
||||
import Header from '../../slots/Header';
|
||||
import SiteContext from '../../slots/SiteContext';
|
||||
import '../../static/style';
|
||||
import IndexLayout from '../IndexLayout';
|
||||
import ResourceLayout from '../ResourceLayout';
|
||||
import SidebarLayout from '../SidebarLayout';
|
||||
|
||||
@ -64,10 +64,9 @@ const DocLayout: React.FC = () => {
|
||||
['/index'].some((path) => pathname.startsWith(path))
|
||||
) {
|
||||
return (
|
||||
<>
|
||||
<div style={{ minHeight: '100vh' }}>{outlet}</div>
|
||||
<Footer />
|
||||
</>
|
||||
<IndexLayout title={locale.title} desc={locale.description}>
|
||||
{outlet}
|
||||
</IndexLayout>
|
||||
);
|
||||
}
|
||||
if (pathname.startsWith('/docs/resource')) {
|
||||
@ -87,13 +86,10 @@ const DocLayout: React.FC = () => {
|
||||
data-direction={direction}
|
||||
className={classNames({ rtl: direction === 'rtl' })}
|
||||
/>
|
||||
<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:description" content={locale.description} />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta
|
||||
|
21
.dumi/theme/layouts/IndexLayout/index.tsx
Normal file
21
.dumi/theme/layouts/IndexLayout/index.tsx
Normal file
@ -0,0 +1,21 @@
|
||||
import { Helmet } from 'dumi';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import React from 'react';
|
||||
import Footer from '../../slots/Footer';
|
||||
|
||||
const IndexLayout: React.FC<PropsWithChildren<{ title: string; desc: string }>> = ({
|
||||
children,
|
||||
...restProps
|
||||
}) => (
|
||||
<>
|
||||
<Helmet>
|
||||
<title>{restProps.title}</title>
|
||||
<meta property="og:title" content={restProps.title} />
|
||||
{restProps.desc && <meta name="description" content={restProps.desc} />}
|
||||
</Helmet>
|
||||
<div style={{ minHeight: '100vh' }}>{children}</div>
|
||||
<Footer />
|
||||
</>
|
||||
);
|
||||
|
||||
export default IndexLayout;
|
Loading…
Reference in New Issue
Block a user