From 88e0f1c5281fd7717520a7818b62ea2e5adacf03 Mon Sep 17 00:00:00 2001 From: plentydev Date: Tue, 12 Nov 2024 14:20:06 +0200 Subject: [PATCH 1/7] feat: output mapped structured data --- apps/web/composables/useStructuredData/useStructuredData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/composables/useStructuredData/useStructuredData.ts b/apps/web/composables/useStructuredData/useStructuredData.ts index 89dcf043a..469152b9c 100644 --- a/apps/web/composables/useStructuredData/useStructuredData.ts +++ b/apps/web/composables/useStructuredData/useStructuredData.ts @@ -87,7 +87,6 @@ export const useStructuredData: useStructuredDataReturn = () => { const metaObject = { '@context': 'https://schema.org', '@type': 'Product', - // sku: sku, name: productGetters.getName(product), category: categoryTreeGetters.getName(categoryTree), releaseDate: '', @@ -99,6 +98,7 @@ export const useStructuredData: useStructuredDataReturn = () => { '@type': 'Organization', name: manufacturer.externalName, }, + sku: productGetters.getSku(product), review: reviews, aggregateRating: { '@type': 'AggregateRating', From 7dfbd3770b05e8cb18d5ffc78b1f48cfa5a813b8 Mon Sep 17 00:00:00 2001 From: plentydev Date: Wed, 13 Nov 2024 12:37:55 +0200 Subject: [PATCH 2/7] refactoring --- .../useStructuredData/useStructuredData.ts | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/apps/web/composables/useStructuredData/useStructuredData.ts b/apps/web/composables/useStructuredData/useStructuredData.ts index 469152b9c..c643ec98d 100644 --- a/apps/web/composables/useStructuredData/useStructuredData.ts +++ b/apps/web/composables/useStructuredData/useStructuredData.ts @@ -66,7 +66,6 @@ export const useStructuredData: useStructuredDataReturn = () => { const { data: productReviews } = useProductReviews(productId); const { data: reviewAverage } = useProductReviewAverage(productId); - const manufacturer = productGetters.getManufacturer(product); let reviews = null; if (reviewAverage.value) { reviews = []; @@ -94,11 +93,6 @@ export const useStructuredData: useStructuredDataReturn = () => { identifier: productGetters.getId(product), description: product.texts.description, disambiguatingDescription: '', - manufacturer: { - '@type': 'Organization', - name: manufacturer.externalName, - }, - sku: productGetters.getSku(product), review: reviews, aggregateRating: { '@type': 'AggregateRating', @@ -109,7 +103,6 @@ export const useStructuredData: useStructuredDataReturn = () => { '@type': 'Offer', priceCurrency: productGetters.getSpecialPriceCurrency(product), price: Number(price.value), - priceValidUntil: productGetters.getVariationAvailableUntil(product), url: null, priceSpecification: [ { @@ -122,10 +115,8 @@ export const useStructuredData: useStructuredDataReturn = () => { }, }, ], - availability: productGetters.isSalable(product) - ? 'https://schema.org/InStock' - : 'https://schema.org/OutOfStock', - itemCondition: null, + availability: productGetters.getMappedAvailability(product), + itemCondition: productGetters.getConditionOfItem(product), }, depth: { '@type': 'QuantitativeValue', @@ -143,7 +134,38 @@ export const useStructuredData: useStructuredDataReturn = () => { '@type': 'QuantitativeValue', value: productGetters.getWeightG(product), }, - }; + } as any; + + // if (productGetters.getSeoManufacturer(product) !== '') { + // metaObject.manufacturer = { + // '@type': 'Organization', + // name: manufacturer.externalName, + // } + // } + + const brand = productGetters.getBrand(product); + if (brand !== '') metaObject.brand = { '@type': 'Brand', 'name': brand }; + + const sku = productGetters.getSku(product); + if (sku !== '') metaObject.sku = sku; + + const gtin = productGetters.getGtin(product); + if (gtin !== '') metaObject.gtin = gtin; + + const gtin8 = productGetters.getGtin8(product); + if (gtin8 !== '') metaObject.gtin8 = gtin8; + + const gtin13 = productGetters.getGtin13(product); + if (gtin13 !== '') metaObject.gtin13 = gtin13; + + const isbn = productGetters.getIsbn(product); + if (isbn !== '') metaObject.isbn = productGetters.getIsbn(product); + + const mpn = productGetters.getMpn(product); + if (mpn !== '') metaObject.mpn = mpn; + + const priceValidUntil = productGetters.getPriceValidUntil(product); + if (priceValidUntil !== '') metaObject.offers.priceValidUntil = priceValidUntil; if (product.prices?.rrp) { metaObject.offers.priceSpecification.push({ @@ -160,7 +182,7 @@ export const useStructuredData: useStructuredDataReturn = () => { script: [ { type: 'application/ld+json', - innerHTML: JSON.stringify(metaObject), + innerHTML: JSON.stringify(metaObject, null, 4), }, ], }); From a2c3cd6d23928141c0cca742038cf6c7723cabbd Mon Sep 17 00:00:00 2001 From: plentydev Date: Mon, 18 Nov 2024 09:03:20 +0200 Subject: [PATCH 3/7] fix lint error --- apps/web/composables/useStructuredData/useStructuredData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/composables/useStructuredData/useStructuredData.ts b/apps/web/composables/useStructuredData/useStructuredData.ts index c643ec98d..2d885ea99 100644 --- a/apps/web/composables/useStructuredData/useStructuredData.ts +++ b/apps/web/composables/useStructuredData/useStructuredData.ts @@ -144,7 +144,7 @@ export const useStructuredData: useStructuredDataReturn = () => { // } const brand = productGetters.getBrand(product); - if (brand !== '') metaObject.brand = { '@type': 'Brand', 'name': brand }; + if (brand !== '') metaObject.brand = { '@type': 'Brand', name: brand }; const sku = productGetters.getSku(product); if (sku !== '') metaObject.sku = sku; From aa714bff3c95143bd97b7ba134b1158abb1c14eb Mon Sep 17 00:00:00 2001 From: abocsan-plenty <129151096+abocsan-plenty@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:18:37 +0200 Subject: [PATCH 4/7] chore: implement seo settings getter --- .../useStructuredData/useStructuredData.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/web/composables/useStructuredData/useStructuredData.ts b/apps/web/composables/useStructuredData/useStructuredData.ts index 2d885ea99..a4baee871 100644 --- a/apps/web/composables/useStructuredData/useStructuredData.ts +++ b/apps/web/composables/useStructuredData/useStructuredData.ts @@ -1,6 +1,6 @@ import type { useStructuredDataReturn } from './types'; import type { SetLogoMeta, SetProductMetaData, UseStructuredDataState } from './types'; -import { categoryTreeGetters, productGetters, reviewGetters } from '@plentymarkets/shop-api'; +import { categoryTreeGetters, productGetters, reviewGetters, productSeoSettingsGetters } from '@plentymarkets/shop-api'; import type { CategoryTreeItem, Product } from '@plentymarkets/shop-api'; import { useProductReviews } from '../useProductReviews'; import { useProductReviewAverage } from '../useProductReviewAverage'; @@ -115,8 +115,8 @@ export const useStructuredData: useStructuredDataReturn = () => { }, }, ], - availability: productGetters.getMappedAvailability(product), - itemCondition: productGetters.getConditionOfItem(product), + availability: productSeoSettingsGetters.getMappedAvailability(product), + itemCondition: productSeoSettingsGetters.getConditionOfItem(product), }, depth: { '@type': 'QuantitativeValue', @@ -143,28 +143,28 @@ export const useStructuredData: useStructuredDataReturn = () => { // } // } - const brand = productGetters.getBrand(product); + const brand = productSeoSettingsGetters.getBrand(product); if (brand !== '') metaObject.brand = { '@type': 'Brand', name: brand }; - const sku = productGetters.getSku(product); + const sku = productSeoSettingsGetters.getSku(product); if (sku !== '') metaObject.sku = sku; - const gtin = productGetters.getGtin(product); + const gtin = productSeoSettingsGetters.getGtin(product); if (gtin !== '') metaObject.gtin = gtin; - const gtin8 = productGetters.getGtin8(product); + const gtin8 = productSeoSettingsGetters.getGtin8(product); if (gtin8 !== '') metaObject.gtin8 = gtin8; - const gtin13 = productGetters.getGtin13(product); + const gtin13 = productSeoSettingsGetters.getGtin13(product); if (gtin13 !== '') metaObject.gtin13 = gtin13; - const isbn = productGetters.getIsbn(product); - if (isbn !== '') metaObject.isbn = productGetters.getIsbn(product); + const isbn = productSeoSettingsGetters.getIsbn(product); + if (isbn !== '') metaObject.isbn = productSeoSettingsGetters.getIsbn(product); - const mpn = productGetters.getMpn(product); + const mpn = productSeoSettingsGetters.getMpn(product); if (mpn !== '') metaObject.mpn = mpn; - const priceValidUntil = productGetters.getPriceValidUntil(product); + const priceValidUntil = productSeoSettingsGetters.getPriceValidUntil(product); if (priceValidUntil !== '') metaObject.offers.priceValidUntil = priceValidUntil; if (product.prices?.rrp) { From 0598d807663a71c152a9114743e495485ec78182 Mon Sep 17 00:00:00 2001 From: plentydev Date: Tue, 26 Nov 2024 16:33:11 +0200 Subject: [PATCH 5/7] add manufacturer to metaObject --- .../composables/useStructuredData/useStructuredData.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/web/composables/useStructuredData/useStructuredData.ts b/apps/web/composables/useStructuredData/useStructuredData.ts index a4baee871..708756ecb 100644 --- a/apps/web/composables/useStructuredData/useStructuredData.ts +++ b/apps/web/composables/useStructuredData/useStructuredData.ts @@ -136,12 +136,8 @@ export const useStructuredData: useStructuredDataReturn = () => { }, } as any; - // if (productGetters.getSeoManufacturer(product) !== '') { - // metaObject.manufacturer = { - // '@type': 'Organization', - // name: manufacturer.externalName, - // } - // } + const manufacturer = productSeoSettingsGetters.getSeoManufacturer(product); + if (manufacturer !== '') metaObject.manufacturer = { '@type': 'Organization', name: manufacturer } const brand = productSeoSettingsGetters.getBrand(product); if (brand !== '') metaObject.brand = { '@type': 'Brand', name: brand }; From c88cf984a39784d73df72a554acf7ab56df79062 Mon Sep 17 00:00:00 2001 From: plentydev Date: Wed, 27 Nov 2024 12:04:29 +0200 Subject: [PATCH 6/7] chore update version in package.json --- .../composables/useStructuredData/useStructuredData.ts | 2 +- package.json | 2 +- yarn.lock | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/web/composables/useStructuredData/useStructuredData.ts b/apps/web/composables/useStructuredData/useStructuredData.ts index 708756ecb..6d6f8e1f7 100644 --- a/apps/web/composables/useStructuredData/useStructuredData.ts +++ b/apps/web/composables/useStructuredData/useStructuredData.ts @@ -137,7 +137,7 @@ export const useStructuredData: useStructuredDataReturn = () => { } as any; const manufacturer = productSeoSettingsGetters.getSeoManufacturer(product); - if (manufacturer !== '') metaObject.manufacturer = { '@type': 'Organization', name: manufacturer } + if (manufacturer !== '') metaObject.manufacturer = { '@type': 'Organization', name: manufacturer }; const brand = productSeoSettingsGetters.getBrand(product); if (brand !== '') metaObject.brand = { '@type': 'Brand', name: brand }; diff --git a/package.json b/package.json index 14a01389c..83b084c83 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lhci:mobile": "lhci autorun" }, "dependencies": { - "@plentymarkets/shop-api": "^0.75.0", + "@plentymarkets/shop-api": "^0.76.0", "@types/applepayjs": "^14.0.8", "@types/drift-zoom": "^1.5.2", "@types/googlepay": "^0.7.6", diff --git a/yarn.lock b/yarn.lock index ba77e6a24..b1a33130c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4237,7 +4237,7 @@ __metadata: "@nuxt/test-utils": ^3.13.1 "@nuxtjs/turnstile": ^0.8.0 "@paypal/paypal-js": 8.1.0 - "@plentymarkets/shop-api": ^0.75.0 + "@plentymarkets/shop-api": ^0.76.0 "@types/applepayjs": ^14.0.8 "@types/drift-zoom": ^1.5.2 "@types/googlepay": ^0.7.6 @@ -4273,14 +4273,14 @@ __metadata: languageName: unknown linkType: soft -"@plentymarkets/shop-api@npm:^0.75.0": - version: 0.75.0 - resolution: "@plentymarkets/shop-api@npm:0.75.0::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40plentymarkets%2Fshop-api%2F0.75.0%2F8a892c521664c403478a7c0c32472e68673e0174" +"@plentymarkets/shop-api@npm:^0.76.0": + version: 0.76.0 + resolution: "@plentymarkets/shop-api@npm:0.76.0::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40plentymarkets%2Fshop-api%2F0.76.0%2Fd646be8eaac7864ff677d3239cc579c4861db501" dependencies: "@vue-storefront/middleware": ^3.10.0 axios: ^1.7.7 consola: ^3.2.3 - checksum: 55f966d8ca08fa60e3e4ef09165430f5a6878e76d44fcea13ef41a595b65bd345bca4d5cdb6a434e509a93614e694f103a2bc0ed6f9fe41593661c8a9c4b1e07 + checksum: 4ad0886188834ee489d53aae347704292b93b6f44dc580553b710bccccd130fe509f9e9d949b2477fe7f85891851e1a61f106f438200244e421eb6b322d64200 languageName: node linkType: hard From 59b0995b51160236ecb48a64ee87f77e642f9698 Mon Sep 17 00:00:00 2001 From: plentydev Date: Wed, 27 Nov 2024 12:11:18 +0200 Subject: [PATCH 7/7] chore add changelog --- docs/changelog/changelog_en.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog/changelog_en.md b/docs/changelog/changelog_en.md index b80243a72..496aa8abd 100644 --- a/docs/changelog/changelog_en.md +++ b/docs/changelog/changelog_en.md @@ -9,7 +9,8 @@ - Added progress loading indicator animation when navigating between pages. - Added Zoom functionality to product images. - New Json Editor -- Added cookie consent management helper functions read more at https://pwa-docs.plentymarkets.com/guide/how-to/cookie#read-and-react-to-a-registered-cookie +- Added cookie consent management helper functions read more at https://pwa-docs.plentymarkets.com/guide/how-to/cookie#read-and-react-to-a-registered-cookie. +- Added dynamic structured data from the SEO config. ### 👷 Changed