Skip to content

Commit

Permalink
fix: preload responsive images (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
chelorope committed Jan 15, 2024
1 parent 075d1c3 commit 5549416
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/runtime/components/nuxt-img.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ export default defineComponent({
},
head () {
if (this.preload === true) {
const isResponsive = Object.values(this.nSizes).every(v => v)
return {
link: [
{
rel: 'preload',
as: 'image',
href: this.nSrc
...(!isResponsive
? { href: this.nSrc }

Check failure on line 34 in src/runtime/components/nuxt-img.vue

View workflow job for this annotation

GitHub Actions / test-unit (ubuntu-latest, 16)

Expected indentation of 14 spaces but found 12
: {

Check failure on line 35 in src/runtime/components/nuxt-img.vue

View workflow job for this annotation

GitHub Actions / test-unit (ubuntu-latest, 16)

Expected indentation of 14 spaces but found 12
href: this.nSizes.src,

Check failure on line 36 in src/runtime/components/nuxt-img.vue

View workflow job for this annotation

GitHub Actions / test-unit (ubuntu-latest, 16)

Expected indentation of 18 spaces but found 16
imagesizes: this.nSizes.sizes,

Check failure on line 37 in src/runtime/components/nuxt-img.vue

View workflow job for this annotation

GitHub Actions / test-unit (ubuntu-latest, 16)

Expected indentation of 18 spaces but found 16
imagesrcset: this.nSizes.srcset

Check failure on line 38 in src/runtime/components/nuxt-img.vue

View workflow job for this annotation

GitHub Actions / test-unit (ubuntu-latest, 16)

Expected indentation of 18 spaces but found 16
})

Check failure on line 39 in src/runtime/components/nuxt-img.vue

View workflow job for this annotation

GitHub Actions / test-unit (ubuntu-latest, 16)

Expected indentation of 16 spaces but found 14
}
]
}
Expand Down

0 comments on commit 5549416

Please sign in to comment.