Skip to content

Commit

Permalink
fix(theme-classic): do not add microdata item prop to trailing breadc…
Browse files Browse the repository at this point in the history
…rumb (#7179)
  • Loading branch information
Josh-Cena authored Apr 15, 2022
1 parent 84d04ed commit 44966e1
Showing 1 changed file with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
function BreadcrumbsItemLink({
children,
href,
isLast,
}: {
children: ReactNode;
href?: string;
href: string | undefined;
isLast: boolean;
}): JSX.Element {
const className = 'breadcrumbs__link';
if (isLast) {
return (
<span className={className} itemProp="name">
{children}
</span>
);
}
return href ? (
<Link className={className} href={href} itemProp="item">
<span itemProp="name">{children}</span>
Expand Down Expand Up @@ -93,17 +102,16 @@ export default function DocBreadcrumbs(): JSX.Element | null {
itemScope
itemType="https://schema.org/BreadcrumbList">
{homePageRoute && <HomeBreadcrumbItem />}
{breadcrumbs.map((item, idx) => (
<BreadcrumbsItem
key={idx}
active={idx === breadcrumbs.length - 1}
index={idx}>
<BreadcrumbsItemLink
href={idx < breadcrumbs.length - 1 ? item.href : undefined}>
{item.label}
</BreadcrumbsItemLink>
</BreadcrumbsItem>
))}
{breadcrumbs.map((item, idx) => {
const isLast = idx === breadcrumbs.length - 1;
return (
<BreadcrumbsItem key={idx} active={isLast} index={idx}>
<BreadcrumbsItemLink href={item.href} isLast={isLast}>
{item.label}
</BreadcrumbsItemLink>
</BreadcrumbsItem>
);
})}
</ul>
</nav>
);
Expand Down

0 comments on commit 44966e1

Please sign in to comment.