11<script lang="ts" setup>
22import type { MaybeRefOrGetter , PropType } from ' vue'
33import type { ImageOptions } from ' @nuxt/image'
4- import type { SerializableHead } from ' unhead/types '
4+ import type { ResolvableLink } from ' @ unhead/vue '
55import type { VPictureProps } from ' ~/components/VPicture.vue'
66
77const props = defineProps ({
@@ -26,7 +26,7 @@ const pictureProps = inject<MaybeRefOrGetter<VPictureProps>>('pictureProps')
2626
2727const $img = useImage ()
2828
29- const options = computed < ImageOptions > (() => {
29+ const options = computed (() => {
3030 if (! pictureProps ) return {}
3131
3232 const picturePropsValue = toValue <VPictureProps >(pictureProps )
@@ -74,7 +74,10 @@ const sources = computed(() => {
7474 if (! src ) return []
7575
7676 const internalFormat
77- = props .format || props .modifiers ?.format || picturePropsValue ?.format || picturePropsValue ?.modifiers ?.format
77+ = props .format
78+ || (props .modifiers ?.format as string | undefined )
79+ || picturePropsValue ?.format
80+ || (picturePropsValue ?.modifiers ?.format as string | undefined )
7881 const formats = internalFormat ?.split (' ,' ) || ($img .options .format ?.length ? [... $img .options .format ] : [' webp' ])
7982
8083 return formats .map ((format : string ) => {
@@ -84,7 +87,7 @@ const sources = computed(() => {
8487 ... options .value ?.modifiers ,
8588 format ,
8689 },
87- })
90+ } as ImageOptions )
8891
8992 return {
9093 media: props .media ,
@@ -104,18 +107,18 @@ const picturePropsValue = pictureProps && toValue<VPictureProps>(pictureProps)
104107const preload = props .preload || (typeof props .preload === ' undefined' && picturePropsValue ?.preload )
105108
106109if (preload ) {
107- const link: NonNullable < SerializableHead [ ' link ' ]>[ number ] = {
110+ const link: ResolvableLink = {
108111 rel: ' preload' ,
109112 as: ' image' ,
110- imagesrcset: sources .value [0 ].srcset ,
113+ imagesrcset: sources .value [0 ]? .srcset ,
111114 nonce: props .nonce ,
112115 ... (typeof preload !== ' boolean' && preload .fetchPriority
113116 ? { fetchpriority: preload .fetchPriority }
114117 : {}),
115118 }
116119
117120 if (sources .value ?.[0 ]?.sizes ) {
118- link .imagesizes = sources .value [0 ].sizes
121+ link .imagesizes = sources .value [0 ]? .sizes
119122 }
120123
121124 useHead ({ link: [link ] })
0 commit comments