@@ -13,6 +13,7 @@ import {useHomePageRoute} from '@docusaurus/theme-common/internal';
13
13
import Link from '@docusaurus/Link' ;
14
14
import { translate } from '@docusaurus/Translate' ;
15
15
import HomeBreadcrumbItem from '@theme/DocBreadcrumbs/Items/Home' ;
16
+ import DocBreadcrumbsStructuredData from '@theme/DocBreadcrumbs/StructuredData' ;
16
17
17
18
import styles from './styles.module.css' ;
18
19
@@ -28,22 +29,13 @@ function BreadcrumbsItemLink({
28
29
} ) : ReactNode {
29
30
const className = 'breadcrumbs__link' ;
30
31
if ( isLast ) {
31
- return (
32
- < span className = { className } itemProp = "name" >
33
- { children }
34
- </ span >
35
- ) ;
32
+ return < span className = { className } > { children } </ span > ;
36
33
}
37
34
return href ? (
38
- < Link className = { className } href = { href } itemProp = "item" >
39
- < span itemProp = "name" > { children } </ span >
35
+ < Link className = { className } href = { href } >
36
+ < span > { children } </ span >
40
37
</ Link >
41
38
) : (
42
- // TODO Google search console doesn't like breadcrumb items without href.
43
- // The schema doesn't seem to require `id` for each `item`, although Google
44
- // insist to infer one, even if it's invalid. Removing `itemProp="item
45
- // name"` for now, since I don't know how to properly fix it.
46
- // See https://github.com/facebook/docusaurus/issues/7241
47
39
< span className = { className } > { children } </ span >
48
40
) ;
49
41
}
@@ -52,26 +44,16 @@ function BreadcrumbsItemLink({
52
44
function BreadcrumbsItem ( {
53
45
children,
54
46
active,
55
- index,
56
- addMicrodata,
57
47
} : {
58
48
children : ReactNode ;
59
49
active ?: boolean ;
60
- index : number ;
61
- addMicrodata : boolean ;
62
50
} ) : ReactNode {
63
51
return (
64
52
< li
65
- { ...( addMicrodata && {
66
- itemScope : true ,
67
- itemProp : 'itemListElement' ,
68
- itemType : 'https://schema.org/ListItem' ,
69
- } ) }
70
53
className = { clsx ( 'breadcrumbs__item' , {
71
54
'breadcrumbs__item--active' : active ,
72
55
} ) } >
73
56
{ children }
74
- < meta itemProp = "position" content = { String ( index + 1 ) } />
75
57
</ li >
76
58
) ;
77
59
}
@@ -85,40 +67,36 @@ export default function DocBreadcrumbs(): ReactNode {
85
67
}
86
68
87
69
return (
88
- < nav
89
- className = { clsx (
90
- ThemeClassNames . docs . docBreadcrumbs ,
91
- styles . breadcrumbsContainer ,
92
- ) }
93
- aria-label = { translate ( {
94
- id : 'theme.docs.breadcrumbs.navAriaLabel' ,
95
- message : 'Breadcrumbs' ,
96
- description : 'The ARIA label for the breadcrumbs' ,
97
- } ) } >
98
- < ul
99
- className = "breadcrumbs"
100
- itemScope
101
- itemType = "https://schema.org/BreadcrumbList" >
102
- { homePageRoute && < HomeBreadcrumbItem /> }
103
- { breadcrumbs . map ( ( item , idx ) => {
104
- const isLast = idx === breadcrumbs . length - 1 ;
105
- const href =
106
- item . type === 'category' && item . linkUnlisted
107
- ? undefined
108
- : item . href ;
109
- return (
110
- < BreadcrumbsItem
111
- key = { idx }
112
- active = { isLast }
113
- index = { idx }
114
- addMicrodata = { ! ! href } >
115
- < BreadcrumbsItemLink href = { href } isLast = { isLast } >
116
- { item . label }
117
- </ BreadcrumbsItemLink >
118
- </ BreadcrumbsItem >
119
- ) ;
120
- } ) }
121
- </ ul >
122
- </ nav >
70
+ < >
71
+ < DocBreadcrumbsStructuredData breadcrumbs = { breadcrumbs } />
72
+ < nav
73
+ className = { clsx (
74
+ ThemeClassNames . docs . docBreadcrumbs ,
75
+ styles . breadcrumbsContainer ,
76
+ ) }
77
+ aria-label = { translate ( {
78
+ id : 'theme.docs.breadcrumbs.navAriaLabel' ,
79
+ message : 'Breadcrumbs' ,
80
+ description : 'The ARIA label for the breadcrumbs' ,
81
+ } ) } >
82
+ < ul className = "breadcrumbs" >
83
+ { homePageRoute && < HomeBreadcrumbItem /> }
84
+ { breadcrumbs . map ( ( item , idx ) => {
85
+ const isLast = idx === breadcrumbs . length - 1 ;
86
+ const href =
87
+ item . type === 'category' && item . linkUnlisted
88
+ ? undefined
89
+ : item . href ;
90
+ return (
91
+ < BreadcrumbsItem key = { idx } active = { isLast } >
92
+ < BreadcrumbsItemLink href = { href } isLast = { isLast } >
93
+ { item . label }
94
+ </ BreadcrumbsItemLink >
95
+ </ BreadcrumbsItem >
96
+ ) ;
97
+ } ) }
98
+ </ ul >
99
+ </ nav >
100
+ </ >
123
101
) ;
124
102
}
0 commit comments