Skip to content

Commit b291460

Browse files
committed
fix: metadata
1 parent 94a555b commit b291460

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

actions/pdp-renderer/render.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@ const productTemplateCache = {};
1212
function toTemplateProductData(baseProduct) {
1313
const primaryImage = getPrimaryImage(baseProduct)?.url;
1414

15+
1516
return {
1617
name: sanitize(baseProduct.name, 'inline'),
1718
description: sanitize(baseProduct.description, 'all'),
1819
externalId: sanitize(baseProduct.externalId, 'no'),
1920
sku: sanitize(baseProduct.sku, 'no'),
2021
__typename: sanitize(baseProduct.__typename, 'no'),
22+
metaDescription: findDescription(baseProduct),
23+
metaKeyword: sanitize(baseProduct.metaKeyword, 'no'),
24+
metaTitle: sanitize(baseProduct.metaTitle, 'no') || sanitize(baseProduct.name, 'no') || 'Product Details',
25+
metaImage: primaryImage,
26+
primaryImage: primaryImage,
2127
options: baseProduct.options ? [...baseProduct.options] : null,
2228
hasImages: baseProduct.images?.length > 0,
2329
imageList: getImageList(primaryImage, baseProduct.images),
2430
priceString: generatePriceString(baseProduct),
25-
metaDescription: findDescription(baseProduct),
26-
metaImage: primaryImage,
27-
primaryImage: primaryImage,
28-
metaTitle: baseProduct.metaTitle || baseProduct.name || 'Product Details',
2931
};
3032
}
3133

test/pdp-renderer.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ const fakeParams = {
4545
describe('pdp-renderer', () => {
4646
const server = useMockServer();
4747

48+
beforeEach(() => {
49+
server.use(handlers.defaultProductTemplate);
50+
});
51+
4852
describe('basic functionality', () => {
4953
test('main should be defined', () => {
5054
expect(action.main).toBeInstanceOf(Function)

0 commit comments

Comments
 (0)