feat(nuxt): add fetchpriority attribute and literal typings for meta components (#6251)

This commit is contained in:
Sanjaiyan Parthipan 2022-08-02 17:38:01 +05:30 committed by GitHub
parent 622c976cec
commit 94d0c08066
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 67 additions and 11 deletions

View File

@ -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<Record<string, any>>
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<FetchPriority>,
integrity: String,
nomodule: Boolean,
nonce: String,
referrerpolicy: String,
referrerpolicy: String as PropType<ReferrerPolicy>,
src: String,
type: String,
/** @deprecated **/
@ -116,8 +124,9 @@ export const Link = defineComponent({
props: {
...globalProps,
as: String,
crossorigin: String,
crossorigin: String as PropType<CrossOrigin>,
disabled: Boolean,
fetchpriority: String as PropType<FetchPriority>,
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<ReferrerPolicy>,
rel: String as PropType<LinkRelationship>,
sizes: String,
title: String,
type: String,
/** @deprecated **/
methods: String,
/** @deprecated **/
target: String
target: String as PropType<Target>
},
setup: setupForUseMeta(link => ({
link: [link]
@ -150,7 +159,7 @@ export const Base = defineComponent({
props: {
...globalProps,
href: String,
target: String
target: String as PropType<Target>
},
setup: setupForUseMeta(base => ({
base
@ -180,7 +189,7 @@ export const Meta = defineComponent({
...globalProps,
charset: String,
content: String,
httpEquiv: String,
httpEquiv: String as PropType<HTTPEquiv>,
name: String
},
setup: setupForUseMeta(meta => ({

View File

@ -0,0 +1,47 @@
export type Props = Readonly<Record<string, any>>
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 & {})