From c2f3a9fd9d0b012a35edb6905f06d437a2f8f9c7 Mon Sep 17 00:00:00 2001 From: "Mark J. Becker" Date: Wed, 20 Nov 2024 16:44:20 +0000 Subject: [PATCH] Include last-modified in metadata --- blocks/product-details/product-details.js | 6 +++--- tools/pdp-metadata/pdp-metadata.js | 6 +++++- tools/pdp-metadata/queries/products.graphql.js | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/blocks/product-details/product-details.js b/blocks/product-details/product-details.js index b61405d12a..079377bb15 100644 --- a/blocks/product-details/product-details.js +++ b/blocks/product-details/product-details.js @@ -109,7 +109,7 @@ function setMetaTags(product) { createMetaTag('description', product.metaDescription, 'name'); createMetaTag('keywords', product.metaKeyword, 'name'); - createMetaTag('og:type', 'og:product', 'property'); + createMetaTag('og:type', 'product', 'property'); createMetaTag('og:description', product.shortDescription, 'property'); createMetaTag('og:title', product.metaTitle || product.name, 'property'); createMetaTag('og:url', window.location.href, 'property'); @@ -117,8 +117,8 @@ function setMetaTags(product) { const metaImage = mainImage?.url || product?.images[0]?.url; createMetaTag('og:image', metaImage, 'property'); createMetaTag('og:image:secure_url', metaImage, 'property'); - createMetaTag('og:product:price:amount', price.value, 'property'); - createMetaTag('og:product:price:currency', price.currency, 'property'); + createMetaTag('product:price:amount', price.value, 'property'); + createMetaTag('product:price:currency', price.currency, 'property'); } export default async function decorate(block) { diff --git a/tools/pdp-metadata/pdp-metadata.js b/tools/pdp-metadata/pdp-metadata.js index 7684618c98..8bced1122c 100644 --- a/tools/pdp-metadata/pdp-metadata.js +++ b/tools/pdp-metadata/pdp-metadata.js @@ -113,6 +113,7 @@ const getProducts = async (config, pageNumber) => { metaTitle, description, shortDescription, + lastModifiedAt, } = item.productView; const { url: imageUrl } = item.productView.images?.[0] ?? { url: '' }; @@ -144,6 +145,7 @@ const getProducts = async (config, pageNumber) => { meta_description: finalDescription, 'og:image': baseImageUrl, 'og:image:secure_url': baseImageUrl, + 'last-modified': lastModifiedAt, }, }; })); @@ -210,6 +212,7 @@ async function addVariantsToProducts(products, config) { 'og:url', 'og:image', 'og:image:secure_url', + 'last-modified', 'json-ld', ], ]; @@ -220,12 +223,13 @@ async function addVariantsToProducts(products, config) { metaData.meta_title, // title metaData.meta_description, // description metaData.meta_keyword, // keywords - 'og:product', // og:type + 'product', // og:type metaData.meta_title, // og:title metaData.meta_description, // og:description `${basePath}${metaData.path}`, // og:url metaData['og:image'], // og:image metaData['og:image:secure_url'], // og:image:secure_url + metaData['last-modified'], // last-modified header getJsonLd(metaData, variants), // json-ld ], ); diff --git a/tools/pdp-metadata/queries/products.graphql.js b/tools/pdp-metadata/queries/products.graphql.js index b5e3f6d3da..d6ab6473d5 100644 --- a/tools/pdp-metadata/queries/products.graphql.js +++ b/tools/pdp-metadata/queries/products.graphql.js @@ -12,6 +12,7 @@ export default `query productSearch($currentPage: Int = 1) { metaDescription metaKeyword metaTitle + lastModifiedAt inStock images(roles: ["image"]) { url