diff --git a/src/components/DsfrHeader/DsfrHeader.types.ts b/src/components/DsfrHeader/DsfrHeader.types.ts index eeffb8e7..4712b343 100644 --- a/src/components/DsfrHeader/DsfrHeader.types.ts +++ b/src/components/DsfrHeader/DsfrHeader.types.ts @@ -12,7 +12,13 @@ export type DsfrHeaderMenuLinkProps = { target?: string onClick?: ($event: MouseEvent) => void to?: RouteLocationRaw + /** + * @deprecated Use the prop `to` instead + */ href?: string + /** + * @deprecated Use the prop `to` instead + */ path?: string } diff --git a/src/components/DsfrHeader/DsfrHeaderMenuLink.vue b/src/components/DsfrHeader/DsfrHeaderMenuLink.vue index 938da873..afe50f9f 100644 --- a/src/components/DsfrHeader/DsfrHeaderMenuLink.vue +++ b/src/components/DsfrHeader/DsfrHeaderMenuLink.vue @@ -21,10 +21,14 @@ const isPathString = computed(() => { return typeof props.path === 'string' }) const isExternalLink = computed(() => { - return props.href?.startsWith('http') || (isPathString.value && (props.path as string).startsWith('http')) + return props.href?.startsWith('http') || + (isPathString.value && (props.path as string).startsWith('http')) || + (typeof props.to === 'string' && (props.to as string).startsWith('http')) }) const isMailto = computed(() => { - return props.href?.startsWith('mailto') || (isPathString.value && (props.path as string).startsWith('mailto')) + return props.href?.startsWith('mailto') || + (isPathString.value && (props.path as string).startsWith('mailto')) || + (typeof props.to === 'string' && (props.to as string).startsWith('mailto')) }) const is = computed(() => { if (props.button) { @@ -37,13 +41,13 @@ const actualHref = computed(() => { if (!isExternalLink.value && !isMailto.value) { return undefined } - return props.href !== undefined ? props.href : props.path + return props.to ?? props.href ?? props.path }) const actualTo = computed(() => { if (isExternalLink.value || isMailto.value) { return undefined } - return props.to || props.path + return props.to ?? props.path }) const linkData = computed(() => { return actualTo.value ? { to: actualTo.value } : { href: actualHref.value }