ant-design/.dumi/theme/common/CommonHelmet.tsx
2022-12-01 12:21:42 +08:00

25 lines
657 B
TypeScript

import { useRouteMeta, Helmet } from 'dumi';
import React, { useMemo } from 'react';
const CommonHelmet = () => {
const meta = useRouteMeta();
const [title, description] = useMemo(() => {
const helmetTitle = `${meta.frontmatter.subtitle || ''} ${
meta.frontmatter?.title
} - Ant Design`;
const helmetDescription = meta.frontmatter.description;
return [helmetTitle, helmetDescription];
}, [meta]);
return (
<Helmet>
<title>{title}</title>
<meta property="og:title" content={title} />
{description && <meta name="description" content={description} />}
</Helmet>
);
};
export default CommonHelmet;