|
1 | 1 | <script lang="ts"> |
2 | 2 | import type { AppConfig } from '@nuxt/schema' |
3 | | -import type { NuxtLinkProps } from '#app' |
| 3 | +import type { RouterLinkProps, RouteLocationRaw } from 'vue-router' |
4 | 4 | import theme from '#build/ui/link' |
5 | 5 | import type { ButtonHTMLAttributes, AnchorHTMLAttributes } from '../types/html' |
6 | 6 | import type { ComponentConfig } from '../types/tv' |
7 | 7 |
|
8 | 8 | type Link = ComponentConfig<typeof theme, AppConfig, 'link'> |
9 | 9 |
|
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'> { |
11 | 62 | /** |
12 | 63 | * The element or component this component should render as when not a link. |
13 | 64 | * @defaultValue 'button' |
|
0 commit comments