diff --git a/src/components/Breadcrumbs.tsx b/src/components/Breadcrumbs.tsx index a9ac2e136..70e5ae5b0 100644 --- a/src/components/Breadcrumbs.tsx +++ b/src/components/Breadcrumbs.tsx @@ -59,7 +59,7 @@ export function Breadcrumbs({ & { - Comp: HeadingLevel -}) => { - // Convert children to array and strip any inner anchor (native 'a' or MarkdownLink) - const childrenArray = React.Children.toArray(children) - const sanitizedChildren = childrenArray.map((child) => { - if ( - React.isValidElement(child) && - (child.type === 'a' || child.type === MarkdownLink) - ) { - // replace anchor child with its own children so outer anchor remains the only link - return (child.props as { children?: React.ReactNode }).children ?? null - } - return child - }) - - const heading = ( - - {sanitizedChildren} - - ) - - if (id) { - return ( - - {heading} - - ) - } - - return heading -} - -const makeHeading = - (type: HeadingLevel) => (props: HTMLProps) => ( - - ) - -const markdownComponents: Record = { - a: MarkdownLink, - pre: CodeBlock, - h1: makeHeading('h1'), - h2: makeHeading('h2'), - h3: makeHeading('h3'), - h4: makeHeading('h4'), - h5: makeHeading('h5'), - h6: makeHeading('h6'), - code: function Code({ className, ...rest }: HTMLProps) { - return ( - - ) - }, - iframe: (props) => ( -