import type { NavItemWithChildren } from '@rspress/core'; import { matchNavbar, useLocation } from '@rspress/core/runtime'; import { Link, Tag } from '@rspress/core/theme'; import cls from 'clsx'; import './index.scss'; type Items = NavItemWithChildren['items']; interface HoverGroupProps { items?: Items; customChildren?: React.ReactNode; isOpen: boolean; /** * @default center */ position?: 'left' | 'center' | 'right'; activeMatcher?: (item: Items[number]) => boolean; } function HoverGroupItem({ item, activeMatcher, depth = 0, }: { item: Items[number]; activeMatcher?: (item: Items[number]) => boolean; depth?: number; }) { const { pathname } = useLocation(); if ('items' in item && item.items && item.items.length > 0) { const hasLink = 'link' in item && item.link; return ( <> {hasLink && (
  • {item.text} {'tag' in item && item.tag && }
  • )} {item.items.map(subItem => ( ))} ); } if ('link' in item) { const { text, link, lang, rel } = item; const download = 'download' in item ? item.download : undefined; const isActiveItem = activeMatcher ? activeMatcher(item) : matchNavbar(item, pathname); return (
  • {link ? ( {text} {'tag' in item && item.tag && } ) : (
    {text} {'tag' in item && item.tag && }
    )}
  • ); } return (
  • {item.text} {'tag' in item && item.tag && }
  • ); } function HoverGroup({ items, customChildren, isOpen, position = 'center', activeMatcher, }: HoverGroupProps) { return ( ); } export type { HoverGroupProps, Items }; export { HoverGroup };