Skip to content

Commit

Permalink
fix: do not pass locale props to NuxtLink (#2499)
Browse files Browse the repository at this point in the history
  • Loading branch information
dadajam4 committed Oct 19, 2023
1 parent b7a8618 commit d485f7f
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/runtime/components/NuxtLinkLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,26 @@ export default defineComponent({
return props.to === '' || hasProtocol(props.to, { acceptRelative: true })
})

return () =>
isExternal.value
? h(NuxtLinkLocale, props, slots.default)
: h(NuxtLinkLocale, { ...props, to: resolvedPath }, slots.default)
/**
* Get props to pass to NuxtLink
* @returns NuxtLink props
*/
const getNuxtLinkProps = () => {
const _props = {
...props
}

if (!isExternal.value) {
_props.to = resolvedPath
}

// The locale attribute cannot be set for NuxtLink
// @see https://github.com/nuxt-modules/i18n/issues/2498
delete _props.locale

return _props
}

return () => h(NuxtLinkLocale, getNuxtLinkProps(), slots.default)
}
})

0 comments on commit d485f7f

Please sign in to comment.