From f5e9d2df450d2f917620fabf0074f847a9bbbe54 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 21 Mar 2024 14:28:12 +0800 Subject: [PATCH] docs: fix Menu ellipsis style (#47997) --- .dumi/hooks/useMenu.tsx | 91 ++++++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 32 deletions(-) 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, ''), })),