Skip to content

Commit

Permalink
fix(useBreadcrumbItems): route meta regression
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Sep 29, 2024
1 parent 96bf770 commit f5a4da6
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/runtime/nuxt/composables/useBreadcrumbItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ function titleCase(s: string) {

export function useBreadcrumbItems(options: BreadcrumbProps = {}) {
const router = useRouter()
const routes = router.getRoutes()

const i18n = useI18n()
const siteResolver = createSitePathResolver({
canonical: true,
Expand Down Expand Up @@ -149,7 +147,7 @@ export function useBreadcrumbItems(options: BreadcrumbProps = {}) {
segments.push(...options.append)
return (segments.filter(Boolean) as BreadcrumbItemProps[])
.map((item) => {
const route = router.resolve(item.to)?.matched
const route = router.resolve(item.to)?.matched?.[0] || router.currentRoute.value // fallback to current route
const routeMeta = (route?.meta || {}) as RouteMeta & { title?: string, breadcrumbLabel: string }
const routeName = route ? String(route.name || route.path) : (item.to === '/' ? 'index' : 'unknown')
let [name] = routeName.split('___')
Expand Down

0 comments on commit f5a4da6

Please sign in to comment.