You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
824 B

import { useRouteMeta, Helmet } from 'dumi';
import React, { useMemo } from 'react';
const CommonHelmet = () => {
const meta = useRouteMeta();
const [title, description] = useMemo(() => {
let helmetTitle;
if (!meta.frontmatter.subtitle && !meta.frontmatter.title) {
helmetTitle = '404 Not Found - Ant Design';
} else {
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;