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:
Ricky 2023-10-07 14:23:52 +08:00 committed by GitHub
parent fc2b4af8cf
commit 24ed2cf364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 8 deletions

View File

@ -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

View 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;