mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-01 03:08:17 +02:00
fix(theme-classic): remove breadcrumb items without href from microdata (#7304)
This commit is contained in:
parent
3a7e6665ad
commit
b3feb01009
2 changed files with 19 additions and 7 deletions
|
@ -40,9 +40,12 @@ function BreadcrumbsItemLink({
|
||||||
<span itemProp="name">{children}</span>
|
<span itemProp="name">{children}</span>
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
<span className={className} itemProp="item name">
|
// TODO Google search console doesn't like breadcrumb items without href.
|
||||||
{children}
|
// The schema doesn't seem to require `id` for each `item`, although Google
|
||||||
</span>
|
// insist to infer one, even if it's invalid. Removing `itemProp="item
|
||||||
|
// name"` for now, since I don't know how to properly fix it.
|
||||||
|
// See https://github.com/facebook/docusaurus/issues/7241
|
||||||
|
<span className={className}>{children}</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,16 +54,20 @@ function BreadcrumbsItem({
|
||||||
children,
|
children,
|
||||||
active,
|
active,
|
||||||
index,
|
index,
|
||||||
|
addMicrodata,
|
||||||
}: {
|
}: {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
index: number;
|
index: number;
|
||||||
|
addMicrodata: boolean;
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
itemScope
|
{...(addMicrodata && {
|
||||||
itemProp="itemListElement"
|
itemScope: true,
|
||||||
itemType="https://schema.org/ListItem"
|
itemProp: 'itemListElement',
|
||||||
|
itemType: 'https://schema.org/ListItem',
|
||||||
|
})}
|
||||||
className={clsx('breadcrumbs__item', {
|
className={clsx('breadcrumbs__item', {
|
||||||
'breadcrumbs__item--active': active,
|
'breadcrumbs__item--active': active,
|
||||||
})}>
|
})}>
|
||||||
|
@ -106,7 +113,11 @@ export default function DocBreadcrumbs(): JSX.Element | null {
|
||||||
{breadcrumbs.map((item, idx) => {
|
{breadcrumbs.map((item, idx) => {
|
||||||
const isLast = idx === breadcrumbs.length - 1;
|
const isLast = idx === breadcrumbs.length - 1;
|
||||||
return (
|
return (
|
||||||
<BreadcrumbsItem key={idx} active={isLast} index={idx}>
|
<BreadcrumbsItem
|
||||||
|
key={idx}
|
||||||
|
active={isLast}
|
||||||
|
index={idx}
|
||||||
|
addMicrodata={!!item.href}>
|
||||||
<BreadcrumbsItemLink href={item.href} isLast={isLast}>
|
<BreadcrumbsItemLink href={item.href} isLast={isLast}>
|
||||||
{item.label}
|
{item.label}
|
||||||
</BreadcrumbsItemLink>
|
</BreadcrumbsItemLink>
|
||||||
|
|
|
@ -158,6 +158,7 @@ mdxast
|
||||||
mdxhast
|
mdxhast
|
||||||
metadatum
|
metadatum
|
||||||
metastring
|
metastring
|
||||||
|
microdata
|
||||||
middlewares
|
middlewares
|
||||||
minifier
|
minifier
|
||||||
mkcert
|
mkcert
|
||||||
|
|
Loading…
Add table
Reference in a new issue