From 44966e19e9a0a606f6f169e7dfc0453d7c534b86 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 15 Apr 2022 22:09:00 +0800 Subject: [PATCH] fix(theme-classic): do not add microdata item prop to trailing breadcrumb (#7179) --- .../src/theme/DocBreadcrumbs/index.tsx | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/docusaurus-theme-classic/src/theme/DocBreadcrumbs/index.tsx b/packages/docusaurus-theme-classic/src/theme/DocBreadcrumbs/index.tsx index 780579774851..d273cc31700c 100644 --- a/packages/docusaurus-theme-classic/src/theme/DocBreadcrumbs/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/DocBreadcrumbs/index.tsx @@ -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 ( + + {children} + + ); + } return href ? ( {children} @@ -93,17 +102,16 @@ export default function DocBreadcrumbs(): JSX.Element | null { itemScope itemType="https://schema.org/BreadcrumbList"> {homePageRoute && } - {breadcrumbs.map((item, idx) => ( - - - {item.label} - - - ))} + {breadcrumbs.map((item, idx) => { + const isLast = idx === breadcrumbs.length - 1; + return ( + + + {item.label} + + + ); + })} );