Skip to content

Commit da8daaa

Browse files
fix(Link): define NuxtLinkProps instead of importing from #app (#5491)
1 parent e75f696 commit da8daaa

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

src/runtime/components/Link.vue

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,64 @@
11
<script lang="ts">
22
import type { AppConfig } from '@nuxt/schema'
3-
import type { NuxtLinkProps } from '#app'
3+
import type { RouterLinkProps, RouteLocationRaw } from 'vue-router'
44
import theme from '#build/ui/link'
55
import type { ButtonHTMLAttributes, AnchorHTMLAttributes } from '../types/html'
66
import type { ComponentConfig } from '../types/tv'
77
88
type Link = ComponentConfig<typeof theme, AppConfig, 'link'>
99
10-
export interface LinkProps extends Omit<NuxtLinkProps, 'custom'>, /** @vue-ignore */ Omit<ButtonHTMLAttributes, 'type' | 'disabled'>, /** @vue-ignore */ Omit<AnchorHTMLAttributes, 'href' | 'target' | 'rel' | 'type'> {
10+
interface NuxtLinkProps extends Omit<RouterLinkProps, 'to'> {
11+
/**
12+
* Route Location the link should navigate to when clicked on.
13+
*/
14+
to?: RouteLocationRaw
15+
/**
16+
* An alias for `to`. If used with `to`, `href` will be ignored
17+
*/
18+
href?: NuxtLinkProps['to']
19+
/**
20+
* Forces the link to be considered as external (true) or internal (false). This is helpful to handle edge-cases
21+
*/
22+
external?: boolean
23+
/**
24+
* Where to display the linked URL, as the name for a browsing context.
25+
*/
26+
target?: '_blank' | '_parent' | '_self' | '_top' | (string & {}) | null
27+
/**
28+
* A rel attribute value to apply on the link. Defaults to "noopener noreferrer" for external links.
29+
*/
30+
rel?: 'noopener' | 'noreferrer' | 'nofollow' | 'sponsored' | 'ugc' | (string & {}) | null
31+
/**
32+
* If set to true, no rel attribute will be added to the link
33+
*/
34+
noRel?: boolean
35+
/**
36+
* A class to apply to links that have been prefetched.
37+
*/
38+
prefetchedClass?: string
39+
/**
40+
* When enabled will prefetch middleware, layouts and payloads of links in the viewport.
41+
*/
42+
prefetch?: boolean
43+
/**
44+
* Allows controlling when to prefetch links. By default, prefetch is triggered only on visibility.
45+
*/
46+
prefetchOn?: 'visibility' | 'interaction' | Partial<{
47+
visibility: boolean
48+
interaction: boolean
49+
}>
50+
/**
51+
* Escape hatch to disable `prefetch` attribute.
52+
*/
53+
noPrefetch?: boolean
54+
/**
55+
* An option to either add or remove trailing slashes in the `href` for this specific link.
56+
* Overrides the global `trailingSlash` option if provided.
57+
*/
58+
trailingSlash?: 'append' | 'remove'
59+
}
60+
61+
export interface LinkProps extends NuxtLinkProps, /** @vue-ignore */ Omit<ButtonHTMLAttributes, 'type' | 'disabled'>, /** @vue-ignore */ Omit<AnchorHTMLAttributes, 'href' | 'target' | 'rel' | 'type'> {
1162
/**
1263
* The element or component this component should render as when not a link.
1364
* @defaultValue 'button'

0 commit comments

Comments
 (0)