--- // Dropdown menu item, optionally with a nested dropend. import { isExternal } from '@shared/lib/url' import Icon from '@ui/Icon.astro' export interface Level3 { title: string url?: string badge?: string } export interface Level2 extends Level3 { icon?: string color?: string children?: Record } interface Props { level1Key: string itemKey: string item: Level2 currentPage: string[] keepOpen?: boolean } const { level1Key, itemKey, item, currentPage, keepOpen = false } = Astro.props const hasChildren = !!item.children const relative = (url?: string) => (isExternal(url) ? url : `./${url}`) const active = level1Key === currentPage[0] && itemKey === currentPage[1] // A group is an ancestor of the current page, not the page itself; only the // link that really points at it may claim aria-current. const isCurrentPage = active && !hasChildren const itemClasses = ['dropdown-item', hasChildren && 'dropdown-toggle', active && 'active', item.color && `text-${item.color}`] --- { hasChildren ? (
) : ( {item.icon && } {item.title} {item.badge && {item.badge}} ) }