diff --git a/packages/nuxt/src/head/runtime/components.ts b/packages/nuxt/src/head/runtime/components.ts index 96e98fc00..4b0479de7 100644 --- a/packages/nuxt/src/head/runtime/components.ts +++ b/packages/nuxt/src/head/runtime/components.ts @@ -1,8 +1,15 @@ -import { defineComponent } from 'vue' +import { defineComponent, PropType } from 'vue' import type { SetupContext } from 'vue' import { useHead } from './composables' - -type Props = Readonly> +import type { + Props, + FetchPriority, + CrossOrigin, + HTTPEquiv, + ReferrerPolicy, + LinkRelationship, + Target +} from './types' const removeUndefinedProps = (props: Props) => Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined)) @@ -66,14 +73,15 @@ export const Script = defineComponent({ ...globalProps, async: Boolean, crossorigin: { - type: [Boolean, String], + type: [Boolean, String as () => CrossOrigin], default: undefined }, defer: Boolean, + fetchpriority: String as PropType, integrity: String, nomodule: Boolean, nonce: String, - referrerpolicy: String, + referrerpolicy: String as PropType, src: String, type: String, /** @deprecated **/ @@ -116,8 +124,9 @@ export const Link = defineComponent({ props: { ...globalProps, as: String, - crossorigin: String, + crossorigin: String as PropType, disabled: Boolean, + fetchpriority: String as PropType, href: String, hreflang: String, imagesizes: String, @@ -128,15 +137,15 @@ export const Link = defineComponent({ type: Boolean, default: undefined }, - referrerpolicy: String, - rel: String, + referrerpolicy: String as PropType, + rel: String as PropType, sizes: String, title: String, type: String, /** @deprecated **/ methods: String, /** @deprecated **/ - target: String + target: String as PropType }, setup: setupForUseMeta(link => ({ link: [link] @@ -150,7 +159,7 @@ export const Base = defineComponent({ props: { ...globalProps, href: String, - target: String + target: String as PropType }, setup: setupForUseMeta(base => ({ base @@ -180,7 +189,7 @@ export const Meta = defineComponent({ ...globalProps, charset: String, content: String, - httpEquiv: String, + httpEquiv: String as PropType, name: String }, setup: setupForUseMeta(meta => ({ diff --git a/packages/nuxt/src/head/runtime/types.ts b/packages/nuxt/src/head/runtime/types.ts new file mode 100644 index 000000000..c7569922a --- /dev/null +++ b/packages/nuxt/src/head/runtime/types.ts @@ -0,0 +1,47 @@ +export type Props = Readonly> + +export type FetchPriority = 'high' | 'low' | 'auto' + +export type CrossOrigin = '' | 'anonymous' | 'use-credentials' + +export type HTTPEquiv = + | 'content-security-policy' + | 'content-type' + | 'default-style' + | 'refresh' + | 'x-ua-compatible' + +export type ReferrerPolicy = + | '' + | 'no-referrer' + | 'no-referrer-when-downgrade' + | 'same-origin' + | 'origin' + | 'strict-origin' + | 'origin-when-cross-origin' + | 'strict-origin-when-cross-origin' + | 'unsafe-url' + +export type LinkRelationship = + | 'alternate' + | 'author' + | 'canonical' + | 'dns-prefetch' + | 'help' + | 'icon' + | 'license' + | 'manifest' + | 'me' + | 'modulepreload' + | 'next' + | 'pingback' + | 'preconnect' + | 'prefetch' + | 'preload' + | 'prerender' + | 'prev' + | 'search' + | 'stylesheet' + | (string & {}) + +export type Target = '_blank' | '_self' | '_parent' | '_top' | (string & {})