Skip to content

Commit

Permalink
fix: ensure breadcrumb schema.org paths are fully resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Mar 11, 2024
1 parent 31f0d70 commit 09a4c6e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/runtime/nuxt/composables/useBreadcrumbItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { NuxtLinkProps } from 'nuxt/app'
import { pathBreadcrumbSegments } from '../../pure/breadcrumbs'
import {
computed,
createSitePathResolver,
defineBreadcrumb,
toValue,
useI18n,
Expand Down Expand Up @@ -115,6 +116,10 @@ export function useBreadcrumbItems(options: BreadcrumbProps = {}) {
const routes = router.getRoutes()

const i18n = useI18n()
const siteResolver = createSitePathResolver({
canonical: true,
absolute: true,
})
const items = computed(() => {
let rootNode = '/'
if (i18n) {
Expand Down Expand Up @@ -193,7 +198,7 @@ export function useBreadcrumbItems(options: BreadcrumbProps = {}) {
id: `#${options.id || 'breadcrumb'}`,
itemListElement: items.value.map(item => ({
name: item.label || item.ariaLabel,
item: item.to,
item: item.to ? siteResolver(item.to) : undefined,
})),
}
})),
Expand Down

0 comments on commit 09a4c6e

Please sign in to comment.