diff --git a/.dumi/hooks/useMenu.tsx b/.dumi/hooks/useMenu.tsx index ac1bbf8870..39232c994d 100644 --- a/.dumi/hooks/useMenu.tsx +++ b/.dumi/hooks/useMenu.tsx @@ -6,19 +6,50 @@ import { useFullSidebarData, useSidebarData } from 'dumi'; import Link from '../theme/common/Link'; import useLocation from './useLocation'; -const ItemTag: React.FC<{ tag?: string; show?: boolean }> = (props) => { - const { tag, show = true } = props; - if (!show || !tag) { - return null; +const MenuItemLabelWithTag: React.FC<{ + before?: React.ReactNode; + after?: React.ReactNode; + link: string; + title: React.ReactNode; + subtitle?: React.ReactNode; + search?: string; + tag?: string; + className?: string; +}> = ({ before, after, link, title, subtitle, search, tag = '', className }) => { + if (!before && !after) { + return ( + + + {title} + {subtitle && {subtitle}} + + {tag && ( + + {tag.replace('VERSION', version)} + + )} + + ); } return ( - - {tag.replace('VERSION', version)} - + + {before} + {title} + {subtitle && {subtitle}} + {after} + ); }; @@ -120,18 +151,15 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] => key: group?.title, children: group.children?.map((item) => ({ label: ( - - {before} - {item?.title} - - {item.frontmatter?.subtitle} - - - {after} - + ), key: item.link.replace(/(-cn$)/g, ''), })), @@ -146,15 +174,14 @@ const useMenu = (options: UseMenuOptions = {}): [MenuProps['items'], string] => result.push( ...list.map((item) => ({ label: ( - - {before} - {item?.title} - - {after} - + ), key: item.link.replace(/(-cn$)/g, ''), })),