diff --git a/.eslintignore b/.eslintignore index 883ae26708..bca24df585 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,4 @@ helix-importer-ui -scripts/preact.js scripts/htm.js scripts/acdl tools/picker diff --git a/README.md b/README.md index 53e926d81b..cfb694ff39 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,14 @@ Additionally, you need to have the following modules and customizations installe 1. magento/module-visual-product-recommendations: Commerce module required for PRex Widget +## Documentation + +Before using the aem-boilerplate, we recommand you to go through the documentation on https://www.aem.live/docs/ and more specifically: +1. [Developer Tutorial](https://www.aem.live/developer/tutorial) +2. [The Anatomy of a Project](https://www.aem.live/developer/anatomy-of-a-project) +3. [Web Performance](https://www.aem.live/developer/keeping-it-100) +4. [Markup, Sections, Blocks, and Auto Blocking](https://www.aem.live/developer/markup-sections-blocks) + ## Installation ```sh diff --git a/blocks/product-details/product-details.js b/blocks/product-details/product-details.js index 0c5c21f315..9579b832e5 100644 --- a/blocks/product-details/product-details.js +++ b/blocks/product-details/product-details.js @@ -353,7 +353,8 @@ function setMetaTags(product) { createMetaTag('title', product.metaTitle || product.name, 'name'); 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'); @@ -361,6 +362,6 @@ 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'); } diff --git a/blocks/product-list-page-custom/FacetList.js b/blocks/product-list-page-custom/FacetList.js index 917fc77b0a..d00058f3e0 100644 --- a/blocks/product-list-page-custom/FacetList.js +++ b/blocks/product-list-page-custom/FacetList.js @@ -1,7 +1,7 @@ /* eslint-disable max-classes-per-file */ import { h, Component, createRef, -} from '../../scripts/preact.js'; +} from '@dropins/tools/preact.js'; import htm from '../../scripts/htm.js'; const html = htm.bind(h); diff --git a/blocks/product-list-page-custom/ProductList.js b/blocks/product-list-page-custom/ProductList.js index 2b4b812cac..0d27e1d3ba 100644 --- a/blocks/product-list-page-custom/ProductList.js +++ b/blocks/product-list-page-custom/ProductList.js @@ -1,7 +1,7 @@ /* eslint-disable object-curly-spacing, class-methods-use-this */ import { h, Component, Fragment, -} from '../../scripts/preact.js'; +} from '@dropins/tools/preact.js'; import htm from '../../scripts/htm.js'; import { renderPrice, diff --git a/blocks/product-list-page-custom/product-list-page-custom.js b/blocks/product-list-page-custom/product-list-page-custom.js index 7eb82161aa..81c7018a06 100644 --- a/blocks/product-list-page-custom/product-list-page-custom.js +++ b/blocks/product-list-page-custom/product-list-page-custom.js @@ -1,6 +1,6 @@ import { h, Component, Fragment, render, createRef, -} from '../../scripts/preact.js'; +} from '@dropins/tools/preact.js'; import htm from '../../scripts/htm.js'; import ProductList from './ProductList.js'; import FacetList from './FacetList.js'; diff --git a/blocks/product-recommendations/product-recommendations.js b/blocks/product-recommendations/product-recommendations.js index 03074fd1d0..31bb3b56c4 100644 --- a/blocks/product-recommendations/product-recommendations.js +++ b/blocks/product-recommendations/product-recommendations.js @@ -66,7 +66,9 @@ function renderPlaceholder(block) { function renderItem(unitId, product) { let image = product.images[0]?.url; - image = image.replace('http://', '//'); + if (image) { + image = image.replace('http://', '//'); + } const clickHandler = () => { window.adobeDataLayer.push((dl) => { diff --git a/draft.robots.txt b/draft.robots.txt new file mode 100644 index 0000000000..1ca581a9f2 --- /dev/null +++ b/draft.robots.txt @@ -0,0 +1,8 @@ +User-agent: * +Allow: / +Disallow: /drafts/ +Disallow: /enrichment/ +Disallow: /tools/ +Disallow: /plugins/experimentation/ + +Sitemap: https://www.aemshop.net/sitemap.xml \ No newline at end of file diff --git a/postinstall.js b/postinstall.js index dc7c8c73fb..1f9c4e6cf0 100644 --- a/postinstall.js +++ b/postinstall.js @@ -31,9 +31,13 @@ fs.readdirSync('node_modules/@dropins', { withFileTypes: true }).forEach((file) }); }); -// Copy eventing specific files -fs.copyFileSync(path.resolve(__dirname, './node_modules/@adobe/magento-storefront-event-collector/dist/index.js'), path.resolve(__dirname, './scripts/commerce-events-collector.js')); -fs.copyFileSync(path.resolve(__dirname, './node_modules/@adobe/magento-storefront-events-sdk/dist/index.js'), path.resolve(__dirname, './scripts/commerce-events-sdk.js')); +// Other files to copy +[ + { from: '@adobe/magento-storefront-event-collector/dist/index.js', to: 'commerce-events-collector.js' }, + { from: '@adobe/magento-storefront-events-sdk/dist/index.js', to: 'commerce-events-sdk.js' }, +].forEach((file) => { + fs.copyFileSync(path.resolve(__dirname, 'node_modules', file.from), path.resolve(__dirname, 'scripts', file.to)); +}); function checkPackageLockForArtifactory() { return new Promise((resolve, reject) => { diff --git a/scripts/aem.js b/scripts/aem.js index 9daeee86dc..ec275180fb 100644 --- a/scripts/aem.js +++ b/scripts/aem.js @@ -100,10 +100,14 @@ function sampleRUM(checkpoint, data) { sampleRUM.enhance = () => { // only enhance once if (document.querySelector('script[src*="rum-enhancer"]')) return; - + const { enhancerVersion, enhancerHash } = sampleRUM.enhancerContext || {}; const script = document.createElement('script'); + if (enhancerHash) { + script.integrity = enhancerHash; + script.setAttribute('crossorigin', 'anonymous'); + } script.src = new URL( - '.rum/@adobe/helix-rum-enhancer@^2/src/index.js', + `.rum/@adobe/helix-rum-enhancer@${enhancerVersion || '^2'}/src/index.js`, sampleRUM.baseURL, ).href; document.head.appendChild(script); diff --git a/scripts/htm.js b/scripts/htm.js index 5e0f466b32..4a6228f9ef 100644 --- a/scripts/htm.js +++ b/scripts/htm.js @@ -1 +1 @@ -var n = function (t, s, r, e) {var u;s[0] = 0;for (var h = 1; h < s.length; h++) {var p = s[h++],a = s[h] ? (s[0] |= p ? 1 : 2, r[s[h++]]) : s[++h];3 === p ? e[0] = a : 4 === p ? e[1] = Object.assign(e[1] || {}, a) : 5 === p ? (e[1] = e[1] || {})[s[++h]] = a : 6 === p ? e[1][s[++h]] += a + "" : p ? (u = t.apply(a, n(t, a, r, ["", null])), e.push(u), a[0] ? s[0] |= 2 : (s[h - 2] = 0, s[h] = u)) : e.push(a);}return e;},t = new Map();export default function (s) {var r = t.get(this);return r || (r = new Map(), t.set(this, r)), (r = n(this, r.get(s) || (r.set(s, r = function (n) {for (var t, s, r = 1, e = "", u = "", h = [0], p = function (n) {1 === r && (n || (e = e.replace(/^\s*\n\s*|\s*\n\s*$/g, ""))) ? h.push(0, n, e) : 3 === r && (n || e) ? (h.push(3, n, e), r = 2) : 2 === r && "..." === e && n ? h.push(4, n, 0) : 2 === r && e && !n ? h.push(5, 0, !0, e) : r >= 5 && ((e || !n && 5 === r) && (h.push(r, 0, e, s), r = 6), n && (h.push(r, n, 0, s), r = 6)), e = "";}, a = 0; a < n.length; a++) {a && (1 === r && p(), p(a));for (var l = 0; l < n[a].length; l++) t = n[a][l], 1 === r ? "<" === t ? (p(), h = [h], r = 3) : e += t : 4 === r ? "--" === e && ">" === t ? (r = 1, e = "") : e = t + e[0] : u ? t === u ? u = "" : e += t : '"' === t || "'" === t ? u = t : ">" === t ? (p(), r = 1) : r && ("=" === t ? (r = 5, s = e, e = "") : "/" === t && (r < 5 || ">" === n[a][l + 1]) ? (p(), 3 === r && (h = h[0]), r = h, (h = h[0]).push(2, 0, r), r = 0) : " " === t || "\t" === t || "\n" === t || "\r" === t ? (p(), r = 2) : e += t), 3 === r && "!--" === e && (r = 4, h = h[0]);}return p(), h;}(s)), r), arguments, [])).length > 1 ? r : r[0];} +var n=function(t,s,r,e){var u;s[0]=0;for(var h=1;h=5&&((e||!n&&5===r)&&(h.push(r,0,e,s),r=6),n&&(h.push(r,n,0,s),r=6)),e=""},a=0;a"===t?(r=1,e=""):e=t+e[0]:u?t===u?u="":e+=t:'"'===t||"'"===t?u=t:">"===t?(p(),r=1):r&&("="===t?(r=5,s=e,e=""):"/"===t&&(r<5||">"===n[a][l+1])?(p(),3===r&&(h=h[0]),r=h,(h=h[0]).push(2,0,r),r=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(p(),r=2):e+=t),3===r&&"!--"===e&&(r=4,h=h[0])}return p(),h}(s)),r),arguments,[])).length>1?r:r[0]} diff --git a/scripts/preact.js b/scripts/preact.js deleted file mode 100644 index 99b57ee96c..0000000000 --- a/scripts/preact.js +++ /dev/null @@ -1 +0,0 @@ -var n,l,u,i,t,o,r,f = {},e = [],c = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function s(n, l) {for (var u in l) n[u] = l[u];return n;}function a(n) {var l = n.parentNode;l && l.removeChild(n);}function h(l, u, i) {var t,o,r,f = {};for (r in u) "key" == r ? t = u[r] : "ref" == r ? o = u[r] : f[r] = u[r];if (arguments.length > 2 && (f.children = arguments.length > 3 ? n.call(arguments, 2) : i), "function" == typeof l && null != l.defaultProps) for (r in l.defaultProps) void 0 === f[r] && (f[r] = l.defaultProps[r]);return v(l, f, t, o, null);}function v(n, i, t, o, r) {var f = { type: n, props: i, key: t, ref: o, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, __h: null, constructor: void 0, __v: null == r ? ++u : r };return null == r && null != l.vnode && l.vnode(f), f;}function y() {return { current: null };}function p(n) {return n.children;}function d(n, l) {this.props = n, this.context = l;}function _(n, l) {if (null == l) return n.__ ? _(n.__, n.__.__k.indexOf(n) + 1) : null;for (var u; l < n.__k.length; l++) if (null != (u = n.__k[l]) && null != u.__e) return u.__e;return "function" == typeof n.type ? _(n) : null;}function k(n) {var l, u;if (null != (n = n.__) && null != n.__c) {for (n.__e = n.__c.base = null, l = 0; l < n.__k.length; l++) if (null != (u = n.__k[l]) && null != u.__e) {n.__e = n.__c.base = u.__e;break;}return k(n);}}function b(n) {(!n.__d && (n.__d = !0) && t.push(n) && !g.__r++ || o !== l.debounceRendering) && ((o = l.debounceRendering) || setTimeout)(g);}function g() {for (var n; g.__r = t.length;) n = t.sort(function (n, l) {return n.__v.__b - l.__v.__b;}), t = [], n.some(function (n) {var l, u, i, t, o, r;n.__d && (o = (t = (l = n).__v).__e, (r = l.__P) && (u = [], (i = s({}, t)).__v = t.__v + 1, j(r, t, i, l.__n, void 0 !== r.ownerSVGElement, null != t.__h ? [o] : null, u, null == o ? _(t) : o, t.__h), z(u, t), t.__e != o && k(t)));});}function w(n, l, u, i, t, o, r, c, s, a) {var h,y,d,k,b,g,w,x = i && i.__k || e,C = x.length;for (u.__k = [], h = 0; h < l.length; h++) if (null != (k = u.__k[h] = null == (k = l[h]) || "boolean" == typeof k ? null : "string" == typeof k || "number" == typeof k || "bigint" == typeof k ? v(null, k, null, null, k) : Array.isArray(k) ? v(p, { children: k }, null, null, null) : k.__b > 0 ? v(k.type, k.props, k.key, k.ref ? k.ref : null, k.__v) : k)) {if (k.__ = u, k.__b = u.__b + 1, null === (d = x[h]) || d && k.key == d.key && k.type === d.type) x[h] = void 0;else for (y = 0; y < C; y++) {if ((d = x[y]) && k.key == d.key && k.type === d.type) {x[y] = void 0;break;}d = null;}j(n, k, d = d || f, t, o, r, c, s, a), b = k.__e, (y = k.ref) && d.ref != y && (w || (w = []), d.ref && w.push(d.ref, null, k), w.push(y, k.__c || b, k)), null != b ? (null == g && (g = b), "function" == typeof k.type && k.__k === d.__k ? k.__d = s = m(k, s, n) : s = A(n, k, d, x, b, s), "function" == typeof u.type && (u.__d = s)) : s && d.__e == s && s.parentNode != n && (s = _(d));}for (u.__e = g, h = C; h--;) null != x[h] && N(x[h], x[h]);if (w) for (h = 0; h < w.length; h++) M(w[h], w[++h], w[++h]);}function m(n, l, u) {for (var i, t = n.__k, o = 0; t && o < t.length; o++) (i = t[o]) && (i.__ = n, l = "function" == typeof i.type ? m(i, l, u) : A(u, i, i, t, i.__e, l));return l;}function x(n, l) {return l = l || [], null == n || "boolean" == typeof n || (Array.isArray(n) ? n.some(function (n) {x(n, l);}) : l.push(n)), l;}function A(n, l, u, i, t, o) {var r, f, e;if (void 0 !== l.__d) r = l.__d, l.__d = void 0;else if (null == u || t != o || null == t.parentNode) n: if (null == o || o.parentNode !== n) n.appendChild(t), r = null;else {for (f = o, e = 0; (f = f.nextSibling) && e < i.length; e += 1) if (f == t) break n;n.insertBefore(t, o), r = o;}return void 0 !== r ? r : t.nextSibling;}function C(n, l, u, i, t) {var o;for (o in u) "children" === o || "key" === o || o in l || H(n, o, null, u[o], i);for (o in l) t && "function" != typeof l[o] || "children" === o || "key" === o || "value" === o || "checked" === o || u[o] === l[o] || H(n, o, l[o], u[o], i);}function $(n, l, u) {"-" === l[0] ? n.setProperty(l, u) : n[l] = null == u ? "" : "number" != typeof u || c.test(l) ? u : u + "px";}function H(n, l, u, i, t) {var o;n: if ("style" === l) {if ("string" == typeof u) n.style.cssText = u;else {if ("string" == typeof i && (n.style.cssText = i = ""), i) for (l in i) u && l in u || $(n.style, l, "");if (u) for (l in u) i && u[l] === i[l] || $(n.style, l, u[l]);}} else if ("o" === l[0] && "n" === l[1]) o = l !== (l = l.replace(/Capture$/, "")), l = l.toLowerCase() in n ? l.toLowerCase().slice(2) : l.slice(2), n.l || (n.l = {}), n.l[l + o] = u, u ? i || n.addEventListener(l, o ? T : I, o) : n.removeEventListener(l, o ? T : I, o);else if ("dangerouslySetInnerHTML" !== l) {if (t) l = l.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");else if ("href" !== l && "list" !== l && "form" !== l && "tabIndex" !== l && "download" !== l && l in n) try {n[l] = null == u ? "" : u;break n;} catch (n) {}"function" == typeof u || (null == u || !1 === u && -1 == l.indexOf("-") ? n.removeAttribute(l) : n.setAttribute(l, u));}}function I(n) {this.l[n.type + !1](l.event ? l.event(n) : n);}function T(n) {this.l[n.type + !0](l.event ? l.event(n) : n);}function j(n, u, i, t, o, r, f, e, c) {var a,h,v,y,_,k,b,g,m,x,A,C,$,H,I,T = u.type;if (void 0 !== u.constructor) return null;null != i.__h && (c = i.__h, e = u.__e = i.__e, u.__h = null, r = [e]), (a = l.__b) && a(u);try {n: if ("function" == typeof T) {if (g = u.props, m = (a = T.contextType) && t[a.__c], x = a ? m ? m.props.value : a.__ : t, i.__c ? b = (h = u.__c = i.__c).__ = h.__E : ("prototype" in T && T.prototype.render ? u.__c = h = new T(g, x) : (u.__c = h = new d(g, x), h.constructor = T, h.render = O), m && m.sub(h), h.props = g, h.state || (h.state = {}), h.context = x, h.__n = t, v = h.__d = !0, h.__h = [], h._sb = []), null == h.__s && (h.__s = h.state), null != T.getDerivedStateFromProps && (h.__s == h.state && (h.__s = s({}, h.__s)), s(h.__s, T.getDerivedStateFromProps(g, h.__s))), y = h.props, _ = h.state, v) null == T.getDerivedStateFromProps && null != h.componentWillMount && h.componentWillMount(), null != h.componentDidMount && h.__h.push(h.componentDidMount);else {if (null == T.getDerivedStateFromProps && g !== y && null != h.componentWillReceiveProps && h.componentWillReceiveProps(g, x), !h.__e && null != h.shouldComponentUpdate && !1 === h.shouldComponentUpdate(g, h.__s, x) || u.__v === i.__v) {for (h.props = g, h.state = h.__s, u.__v !== i.__v && (h.__d = !1), h.__v = u, u.__e = i.__e, u.__k = i.__k, u.__k.forEach(function (n) {n && (n.__ = u);}), A = 0; A < h._sb.length; A++) h.__h.push(h._sb[A]);h._sb = [], h.__h.length && f.push(h);break n;}null != h.componentWillUpdate && h.componentWillUpdate(g, h.__s, x), null != h.componentDidUpdate && h.__h.push(function () {h.componentDidUpdate(y, _, k);});}if (h.context = x, h.props = g, h.__v = u, h.__P = n, C = l.__r, $ = 0, "prototype" in T && T.prototype.render) {for (h.state = h.__s, h.__d = !1, C && C(u), a = h.render(h.props, h.state, h.context), H = 0; H < h._sb.length; H++) h.__h.push(h._sb[H]);h._sb = [];} else do {h.__d = !1, C && C(u), a = h.render(h.props, h.state, h.context), h.state = h.__s;} while (h.__d && ++$ < 25);h.state = h.__s, null != h.getChildContext && (t = s(s({}, t), h.getChildContext())), v || null == h.getSnapshotBeforeUpdate || (k = h.getSnapshotBeforeUpdate(y, _)), I = null != a && a.type === p && null == a.key ? a.props.children : a, w(n, Array.isArray(I) ? I : [I], u, i, t, o, r, f, e, c), h.base = u.__e, u.__h = null, h.__h.length && f.push(h), b && (h.__E = h.__ = null), h.__e = !1;} else null == r && u.__v === i.__v ? (u.__k = i.__k, u.__e = i.__e) : u.__e = L(i.__e, u, i, t, o, r, f, c);(a = l.diffed) && a(u);} catch (n) {u.__v = null, (c || null != r) && (u.__e = e, u.__h = !!c, r[r.indexOf(e)] = null), l.__e(n, u, i);}}function z(n, u) {l.__c && l.__c(u, n), n.some(function (u) {try {n = u.__h, u.__h = [], n.some(function (n) {n.call(u);});} catch (n) {l.__e(n, u.__v);}});}function L(l, u, i, t, o, r, e, c) {var s,h,v,y = i.props,p = u.props,d = u.type,k = 0;if ("svg" === d && (o = !0), null != r) for (; k < r.length; k++) if ((s = r[k]) && "setAttribute" in s == !!d && (d ? s.localName === d : 3 === s.nodeType)) {l = s, r[k] = null;break;}if (null == l) {if (null === d) return document.createTextNode(p);l = o ? document.createElementNS("http://www.w3.org/2000/svg", d) : document.createElement(d, p.is && p), r = null, c = !1;}if (null === d) y === p || c && l.data === p || (l.data = p);else {if (r = r && n.call(l.childNodes), h = (y = i.props || f).dangerouslySetInnerHTML, v = p.dangerouslySetInnerHTML, !c) {if (null != r) for (y = {}, k = 0; k < l.attributes.length; k++) y[l.attributes[k].name] = l.attributes[k].value;(v || h) && (v && (h && v.__html == h.__html || v.__html === l.innerHTML) || (l.innerHTML = v && v.__html || ""));}if (C(l, p, y, o, c), v) u.__k = [];else if (k = u.props.children, w(l, Array.isArray(k) ? k : [k], u, i, t, o && "foreignObject" !== d, r, e, r ? r[0] : i.__k && _(i, 0), c), null != r) for (k = r.length; k--;) null != r[k] && a(r[k]);c || ("value" in p && void 0 !== (k = p.value) && (k !== l.value || "progress" === d && !k || "option" === d && k !== y.value) && H(l, "value", k, y.value, !1), "checked" in p && void 0 !== (k = p.checked) && k !== l.checked && H(l, "checked", k, y.checked, !1));}return l;}function M(n, u, i) {try {"function" == typeof n ? n(u) : n.current = u;} catch (n) {l.__e(n, i);}}function N(n, u, i) {var t, o;if (l.unmount && l.unmount(n), (t = n.ref) && (t.current && t.current !== n.__e || M(t, null, u)), null != (t = n.__c)) {if (t.componentWillUnmount) try {t.componentWillUnmount();} catch (n) {l.__e(n, u);}t.base = t.__P = null, n.__c = void 0;}if (t = n.__k) for (o = 0; o < t.length; o++) t[o] && N(t[o], u, i || "function" != typeof n.type);i || null == n.__e || a(n.__e), n.__ = n.__e = n.__d = void 0;}function O(n, l, u) {return this.constructor(n, u);}function P(u, i, t) {var o, r, e;l.__ && l.__(u, i), r = (o = "function" == typeof t) ? null : t && t.__k || i.__k, e = [], j(i, u = (!o && t || i).__k = h(p, null, [u]), r || f, f, void 0 !== i.ownerSVGElement, !o && t ? [t] : r ? null : i.firstChild ? n.call(i.childNodes) : null, e, !o && t ? t : r ? r.__e : i.firstChild, o), z(e, u);}function S(n, l) {P(n, l, S);}function q(l, u, i) {var t,o,r,f = s({}, l.props);for (r in u) "key" == r ? t = u[r] : "ref" == r ? o = u[r] : f[r] = u[r];return arguments.length > 2 && (f.children = arguments.length > 3 ? n.call(arguments, 2) : i), v(l.type, f, t || l.key, o || l.ref, null);}function B(n, l) {var u = { __c: l = "__cC" + r++, __: n, Consumer: function (n, l) {return n.children(l);}, Provider: function (n) {var u, i;return this.getChildContext || (u = [], (i = {})[l] = this, this.getChildContext = function () {return i;}, this.shouldComponentUpdate = function (n) {this.props.value !== n.value && u.some(b);}, this.sub = function (n) {u.push(n);var l = n.componentWillUnmount;n.componentWillUnmount = function () {u.splice(u.indexOf(n), 1), l && l.call(n);};}), n.children;} };return u.Provider.__ = u.Consumer.contextType = u;}n = e.slice, l = { __e: function (n, l, u, i) {for (var t, o, r; l = l.__;) if ((t = l.__c) && !t.__) try {if ((o = t.constructor) && null != o.getDerivedStateFromError && (t.setState(o.getDerivedStateFromError(n)), r = t.__d), null != t.componentDidCatch && (t.componentDidCatch(n, i || {}), r = t.__d), r) return t.__E = t;} catch (l) {n = l;}throw n;} }, u = 0, i = function (n) {return null != n && void 0 === n.constructor;}, d.prototype.setState = function (n, l) {var u;u = null != this.__s && this.__s !== this.state ? this.__s : this.__s = s({}, this.state), "function" == typeof n && (n = n(s({}, u), this.props)), n && s(u, n), null != n && this.__v && (l && this._sb.push(l), b(this));}, d.prototype.forceUpdate = function (n) {this.__v && (this.__e = !0, n && this.__h.push(n), b(this));}, d.prototype.render = p, t = [], g.__r = 0, r = 0;export { d as Component, p as Fragment, q as cloneElement, B as createContext, h as createElement, y as createRef, h, S as hydrate, i as isValidElement, l as options, P as render, x as toChildArray }; diff --git a/tools/pdp-metadata/pdp-metadata.js b/tools/pdp-metadata/pdp-metadata.js index d83440481e..5baf32e662 100644 --- a/tools/pdp-metadata/pdp-metadata.js +++ b/tools/pdp-metadata/pdp-metadata.js @@ -108,6 +108,7 @@ const getProducts = async (config, pageNumber) => { metaTitle, description, shortDescription, + lastModifiedAt, } = item.productView; const { url: imageUrl } = item.productView.images?.[0] ?? { url: '' }; @@ -139,6 +140,7 @@ const getProducts = async (config, pageNumber) => { meta_description: finalDescription, 'og:image': baseImageUrl, 'og:image:secure_url': baseImageUrl, + 'last-modified': lastModifiedAt, }, }; })); @@ -205,6 +207,7 @@ async function addVariantsToProducts(products, config) { 'og:url', 'og:image', 'og:image:secure_url', + 'last-modified', 'json-ld', ], ]; @@ -215,12 +218,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