Skip to content

Commit c3e0eaa

Browse files
committed
chore(template): seo optimization
Signed-off-by: Frederik Bußmann <frederik@bussmann.io>
1 parent 7ccb129 commit c3e0eaa

11 files changed

Lines changed: 33 additions & 9 deletions

File tree

bun.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

template/app/components/Logo.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const { data: logo } = await useStorefrontData('logo', `#graphql
3131
class="h-5 w-auto hue-rotate-300"
3232
width="50"
3333
height="22"
34+
loading="eager"
3435
/>
3536

3637
Nuxt Shopify

template/app/components/collection/Grid.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const { data: collections } = await useStorefrontData(`collections-${locale.valu
4343
:src="collection.image.url"
4444
:alt="collection.image.altText || collection.title"
4545
class="rounded-md object-cover aspect-square"
46+
sizes="xs:100vw sm:50vw lg:33vw xl:33vw"
4647
:width="600"
4748
:height="600"
4849
/>

template/app/components/collection/Products.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,11 @@ watch(() => collection.value?.products.pageInfo, async () => await nextTick().th
124124

125125
<div class="grid w-full grid-cols-1 gap-16 md:grid-cols-2 xl:grid-cols-3">
126126
<ProductCard
127-
v-for="product in products"
127+
v-for="(product, index) in products"
128128
:key="product.id"
129129
:product="product"
130130
class="pb-14 border-b border-b-default"
131+
:loading="index === 0 ? 'eager' : 'lazy'"
131132
carousel
132133
/>
133134
</div>

template/app/components/collection/Slider.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const props = defineProps<{
1212
sortKey?: string
1313
reverse?: boolean
1414
filters?: ProductFilter[]
15+
loading?: 'eager' | 'lazy'
1516
}>()
1617
1718
const { language, country } = useLocalization()
@@ -75,13 +76,16 @@ const { data: products } = await useStorefrontData(key, `#graphql
7576

7677
<template>
7778
<UCarousel
78-
v-slot="{ item: product }"
79+
v-slot="{ item: product, index }"
7980
:items="products"
8081
class="w-full mb-6"
8182
:ui="{ item: 'md:basis-1/2 lg:basis-1/3' }"
8283
arrows
8384
loop
8485
>
85-
<ProductCard :product="product" />
86+
<ProductCard
87+
:product="product"
88+
:loading="index === 0 ? props.loading : 'lazy'"
89+
/>
8690
</UCarousel>
8791
</template>

template/app/components/product/Card.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { ProductFieldsFragment } from '#shopify/storefront'
44
const props = defineProps<{
55
product: ProductFieldsFragment
66
carousel?: boolean
7+
loading?: 'eager' | 'lazy'
78
}>()
89
910
const localePath = useLocalePath()
@@ -27,7 +28,7 @@ const variant = ref(variants.value[0])
2728
<div class="group relative rounded-md overflow-hidden mb-4">
2829
<UCarousel
2930
v-if="carousel && images.length > 1"
30-
v-slot="{ item }"
31+
v-slot="{ item, index }"
3132
:items="images"
3233
:ui="{
3334
prev: 'left-3! transition-opacity duration-150 lg:opacity-0 lg:group-hover:opacity-100',
@@ -37,15 +38,21 @@ const variant = ref(variants.value[0])
3738
loop
3839
>
3940
<NuxtLink :to="url">
40-
<ProductImage :image="item" />
41+
<ProductImage
42+
:image="item"
43+
:loading="index === 0 ? props.loading : 'lazy'"
44+
/>
4145
</NuxtLink>
4246
</UCarousel>
4347

4448
<NuxtLink
4549
v-else
4650
:to="url"
4751
>
48-
<ProductImage :image="images?.[0] ?? undefined" />
52+
<ProductImage
53+
:image="images?.[0] ?? undefined"
54+
:loading="props.loading"
55+
/>
4956

5057
<ProductImage
5158
v-if="images?.[1]"

template/app/components/product/Gallery.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ watch(() => props.selectedVariant, () => carousel.value?.emblaApi?.scrollTo(0))
3232
<UCarousel
3333
v-if="sliderImages.length > 1"
3434
ref="carousel"
35-
v-slot="{ item }"
35+
v-slot="{ item, index }"
3636
:items="sliderImages"
3737
:ui="{
3838
prev: 'left-3!',
@@ -42,13 +42,17 @@ watch(() => props.selectedVariant, () => carousel.value?.emblaApi?.scrollTo(0))
4242
arrows
4343
loop
4444
>
45-
<ProductImage :image="item" />
45+
<ProductImage
46+
:image="item"
47+
:loading="index === 0 ? 'eager' : 'lazy'"
48+
/>
4649
</UCarousel>
4750

4851
<ProductImage
4952
v-else
5053
:image="sliderImages[0]"
5154
class="mb-6 lg:mb-8"
55+
loading="eager"
5256
/>
5357

5458
<div

template/app/components/product/Image.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Image } from '#shopify/storefront'
44
const props = defineProps<{
55
image?: Partial<Image>
66
title?: string
7+
loading?: 'eager' | 'lazy'
78
}>()
89
910
const emits = defineEmits<{
@@ -36,6 +37,7 @@ const handleImageLoad = () => requestAnimationFrame(() => {
3637
:height="props.image?.height ?? undefined"
3738
sizes="xs:100vw md:50vw lg:40vw xl:25vw"
3839
class="aspect-square max-w-full max-h-full animate-pop-up select-none object-contain"
40+
:loading="props.loading ?? 'lazy'"
3941
placeholder
4042
@load="handleImageLoad"
4143
/>

template/app/pages/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ useSeoMeta({
2525
<CollectionSlider
2626
handle="featured"
2727
:first="12"
28+
loading="eager"
2829
/>
2930
</div>
3031

template/nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
export default defineNuxtConfig({
33
modules: [
44
'../src/module',
5+
'@nuxtjs/critters',
56
'@nuxtjs/i18n',
67
'@nuxt/image',
78
'@nuxt/ui',

0 commit comments

Comments
 (0)