UNPKG

4.15 kBTypeScriptView Raw
1
2//#region lib/router/links.d.ts
3type Primitive = null | undefined | string | number | boolean | symbol | bigint;
4type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
5interface HtmlLinkProps {
6 /**
7 * Address of the hyperlink
8 */
9 href?: string;
10 /**
11 * How the element handles crossorigin requests
12 */
13 crossOrigin?: "anonymous" | "use-credentials";
14 /**
15 * Relationship between the document containing the hyperlink and the destination resource
16 */
17 rel: LiteralUnion<"alternate" | "dns-prefetch" | "icon" | "manifest" | "modulepreload" | "next" | "pingback" | "preconnect" | "prefetch" | "preload" | "prerender" | "search" | "stylesheet", string>;
18 /**
19 * Applicable media: "screen", "print", "(max-width: 764px)"
20 */
21 media?: string;
22 /**
23 * Integrity metadata used in Subresource Integrity checks
24 */
25 integrity?: string;
26 /**
27 * Language of the linked resource
28 */
29 hrefLang?: string;
30 /**
31 * Hint for the type of the referenced resource
32 */
33 type?: string;
34 /**
35 * Referrer policy for fetches initiated by the element
36 */
37 referrerPolicy?: "" | "no-referrer" | "no-referrer-when-downgrade" | "same-origin" | "origin" | "strict-origin" | "origin-when-cross-origin" | "strict-origin-when-cross-origin" | "unsafe-url";
38 /**
39 * Sizes of the icons (for rel="icon")
40 */
41 sizes?: string;
42 /**
43 * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
44 */
45 as?: LiteralUnion<"audio" | "audioworklet" | "document" | "embed" | "fetch" | "font" | "frame" | "iframe" | "image" | "manifest" | "object" | "paintworklet" | "report" | "script" | "serviceworker" | "sharedworker" | "style" | "track" | "video" | "worker" | "xslt", string>;
46 /**
47 * Color to use when customizing a site's icon (for rel="mask-icon")
48 */
49 color?: string;
50 /**
51 * Whether the link is disabled
52 */
53 disabled?: boolean;
54 /**
55 * The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
56 */
57 title?: string;
58 /**
59 * Images to use in different situations, e.g., high-resolution displays,
60 * small monitors, etc. (for rel="preload")
61 */
62 imageSrcSet?: string;
63 /**
64 * Image sizes for different page layouts (for rel="preload")
65 */
66 imageSizes?: string;
67}
68interface HtmlLinkPreloadImage extends HtmlLinkProps {
69 /**
70 * Relationship between the document containing the hyperlink and the destination resource
71 */
72 rel: "preload";
73 /**
74 * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
75 */
76 as: "image";
77 /**
78 * Address of the hyperlink
79 */
80 href?: string;
81 /**
82 * Images to use in different situations, e.g., high-resolution displays,
83 * small monitors, etc. (for rel="preload")
84 */
85 imageSrcSet: string;
86 /**
87 * Image sizes for different page layouts (for rel="preload")
88 */
89 imageSizes?: string;
90}
91/**
92 * Represents a `<link>` element.
93 *
94 * WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
95 */
96type HtmlLinkDescriptor = (HtmlLinkProps & Pick<Required<HtmlLinkProps>, "href">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "imageSizes">) | (HtmlLinkPreloadImage & Pick<Required<HtmlLinkPreloadImage>, "href"> & {
97 imageSizes?: never;
98});
99interface PageLinkDescriptor extends Omit<HtmlLinkDescriptor, "href" | "rel" | "type" | "sizes" | "imageSrcSet" | "imageSizes" | "as" | "color" | "title"> {
100 /**
101 * A [`nonce`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/nonce)
102 * attribute to render on the [`<link>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link)
103 * element. If not provided in Framework Mode, it will default to any
104 * {@link ServerRouter | `<ServerRouter nonce>`} prop.
105 */
106 nonce?: string | undefined;
107 /**
108 * The absolute path of the page to prefetch, e.g. `/absolute/path`.
109 */
110 page: string;
111}
112type LinkDescriptor = HtmlLinkDescriptor | PageLinkDescriptor;
113//#endregion
114export { HtmlLinkDescriptor, LinkDescriptor, PageLinkDescriptor };
\No newline at end of file