From c7a4c8c34fba122efd4fc2e8b5e74357351b564f Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Fri, 15 Apr 2022 21:51:25 +0800 Subject: [PATCH] fix(theme-classic): do not add microdata item prop to trailing breadcrumb --- .../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} + + + ); + })} );