import React from 'react'; import { ContentsNavItemProps, ContentsNavProps } from './types'; import clsx from 'clsx'; const ContentsNavItem = ({ children, isCurrent, href, linkComponent }: ContentsNavItemProps) => { const classNames = ['ds_contents-nav__link']; let ariaCurrent: React.AriaAttributes["aria-current"]; if (isCurrent) { classNames.push('ds_current'); ariaCurrent = 'page'; } const classNamesString = clsx(classNames); function processChildren(children: React.ReactNode) { if (linkComponent) { return linkComponent({ className: classNamesString, href, children }); } else if (href) { return {children}; } else { return {children}; } } return (
  • {processChildren(children)}
  • ); }; const ContentsNav = ({ ariaLabel = 'Pages in this section', children, className, title = 'Contents', ...props }: ContentsNavProps) => { return ( ); }; ContentsNav.displayName = 'ContentsNav'; ContentsNavItem.displayName = 'ContentsNav.Item'; ContentsNav.Item = ContentsNavItem; export default ContentsNav;