@@ -11,7 +11,6 @@ import {
11
11
defineBreadcrumb ,
12
12
toValue ,
13
13
useI18n ,
14
- useRoute ,
15
14
useRouter ,
16
15
useSchemaOrg ,
17
16
useSiteConfig ,
@@ -154,7 +153,7 @@ export function useBreadcrumbItems(options: BreadcrumbProps = {}) {
154
153
const routeMeta = ( route ?. meta || { } ) as RouteMeta & { title ?: string , breadcrumbLabel : string }
155
154
const routeName = route ? String ( route . name || route . path ) : ( item . to === '/' ? 'index' : 'unknown' )
156
155
let [ name ] = routeName . split ( '___' )
157
- if ( name === 'unknown' )
156
+ if ( name === 'unknown' || name . includes ( '/' ) )
158
157
name = ( item . to || '' ) . split ( '/' ) . pop ( ) || '' // fallback to last path segment
159
158
// merge with the route meta
160
159
if ( routeMeta . breadcrumb ) {
@@ -167,14 +166,11 @@ export function useBreadcrumbItems(options: BreadcrumbProps = {}) {
167
166
// @ts -expect-error untyped
168
167
item . label = item . label || routeMeta . breadcrumbTitle || routeMeta . title
169
168
if ( typeof item . label === 'undefined' ) {
170
- // try use i18n
171
- // fetch from i18n
172
- // @ts -expect-error untyped
173
- item . label = item . label || i18n . t ( `breadcrumb.items.${ name } .label` , name === 'index' ? 'Home' : titleCase ( name ) , { missingWarn : false } )
174
- // @ts -expect-error untyped
175
- item . ariaLabel = item . ariaLabel || i18n . t ( `breadcrumb.items.${ name } .ariaLabel` , item . label , { missingWarn : false } )
169
+ item . label = i18n . t ( `breadcrumb.items.${ name } .label` , name === 'index' ? 'Home' : titleCase ( name ) , { missingWarn : false } )
170
+ }
171
+ if ( typeof item . ariaLabel === 'undefined' ) {
172
+ item . ariaLabel = i18n . t ( `breadcrumb.items.${ name } .ariaLabel` , item . label , { missingWarn : false } ) || item . label
176
173
}
177
- item . ariaLabel = item . ariaLabel || item . label
178
174
// mark the current based on the options
179
175
item . current = item . current || item . to === current
180
176
if ( toValue ( options . hideCurrent ) && item . current )
0 commit comments