Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions packages/nuxt/src/head/runtime/components.ts
Original file line number Diff line number Diff line change
@@ -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))
Expand Down Expand Up @@ -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 **/
Expand Down Expand Up @@ -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,
Expand All @@ -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]
Expand All @@ -150,7 +159,7 @@ export const Base = defineComponent({
props: {
...globalProps,
href: String,
target: String
target: String as PropType<Target>
},
setup: setupForUseMeta(base => ({
base
Expand Down Expand Up @@ -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 => ({
Expand Down
47 changes: 47 additions & 0 deletions packages/nuxt/src/head/runtime/types.ts
Original file line number Diff line number Diff line change
@@ -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 & {})