Skip to content

Commit

Permalink
fix: useBreadcrumbItems generating invalid schema.org
Browse files Browse the repository at this point in the history
Fixes #275
  • Loading branch information
harlan-zw committed Jul 20, 2024
1 parent f49bc4b commit e321b80
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/runtime/nuxt/composables/useBreadcrumbItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,16 @@ export function useBreadcrumbItems(options: BreadcrumbProps = {}) {
})

const schemaOrgEnabled = typeof options.schemaOrg === 'undefined' ? true : options.schemaOrg
if (import.meta.server && schemaOrgEnabled) {
// TODO can probably drop this schemaOrgEnabled flag as we mock the function
if ((import.meta.dev || import.meta.server) && schemaOrgEnabled) {
useSchemaOrg([
defineBreadcrumb(computed(() => {
return {
id: `#${options.id || 'breadcrumb'}`,
itemListElement: items.value.map(item => ({
name: item.label || item.ariaLabel,
item: item.to ? siteResolver(item.to) : undefined,
})),
}
})),
defineBreadcrumb({
id: `#${options.id || 'breadcrumb'}`,
itemListElement: computed(() => items.value.map(item => ({
name: item.label || item.ariaLabel,
item: item.to ? siteResolver(item.to) : undefined,
}))),
}),
])
}
return items
Expand Down

0 comments on commit e321b80

Please sign in to comment.