Skip to content

Commit

Permalink
Merge pull request #639 from hlxsites/637-minor-converter-update-product
Browse files Browse the repository at this point in the history
637-minor-converter-update-product-page
  • Loading branch information
rgravitvl authored Jan 4, 2024
2 parents 6889219 + 7e7eff8 commit f19e996
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
5 changes: 0 additions & 5 deletions tools/actions/convert/test/fixtures/product-converted.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
</div>
<hr>
<div class="product-specifications">
<div>
<div></div>
</div>
</div>
<div class="product-attributes">
<div>
<div>Specifications</div>
<div>specifications</div>
Expand Down
5 changes: 0 additions & 5 deletions tools/actions/convert/test/fixtures/product1-converted.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,6 @@ <h2>Streamlined Workflow</h2>
</div>
<hr>
<div class="product-specifications">
<div>
<div></div>
</div>
</div>
<div class="product-attributes">
<div>
<div>Dimensions</div>
<div>dimensions</div>
Expand Down
5 changes: 0 additions & 5 deletions tools/actions/convert/test/fixtures/product2-converted.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ <h2>Enhanced for stem cell applications*</h2>
</div>
<hr>
<div class="product-specifications">
<div>
<div></div>
</div>
</div>
<div class="product-attributes">
<div>
<div>Imaging</div>
<div>imaging</div>
Expand Down
5 changes: 0 additions & 5 deletions tools/actions/convert/test/fixtures/product3-converted.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@ <h2>The Microhub era is now!</h2>
</div>
<hr>
<div class="product-specifications">
<div>
<div></div>
</div>
</div>
<div class="product-attributes">
<div>
<div>Dimensions</div>
<div>dimensions</div>
Expand Down
9 changes: 9 additions & 0 deletions tools/importer/transformers/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ const addCategoryMeta = (url, meta) => {
}
};

const addSKUMeta = (url, meta) => {
// detect family|sku|budle pages based on url and set sku metadata
if (url.pathname.match(/\/content\/danaher\/ls\/us\/en\/products\/(family\/|sku\/|bundle\/)/)) {
const sku = url.pathname.replace(/^\/content\/danaher\/ls\/us\/en\/products\//, '').replace(/\.html$/, '').split('/');
meta.sku = sku.pop();
}
};

// eslint-disable-next-line no-unused-vars
const createMetadata = (main, document, html, params, urlStr) => {
const meta = {};
Expand Down Expand Up @@ -147,6 +155,7 @@ const createMetadata = (main, document, html, params, urlStr) => {
addArticleMeta(document, meta);
addDataLayerMeta(document, html, meta);
addCategoryMeta(urlStr, meta);
addSKUMeta(urlStr, meta);

const block = WebImporter.Blocks.getMetadataBlock(document, meta);
main.append(block);
Expand Down
14 changes: 7 additions & 7 deletions tools/importer/transformers/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
/* global WebImporter */

const TABS_MAPPING = [
{ id: 'feature' },
{ id: 'overview', sectionName: 'Product Overview' },
{ id: 'specification', sectionName: 'Product Specifications' },
{ id: 'solutions', sectionName: 'Product Solutions' },
Expand Down Expand Up @@ -59,19 +60,18 @@ const createProductPage = (main, document) => {
const attributeCells = [];
const template = product.querySelector(`template[v-slot:${tab.tabId}]`);
const tabConfig = TABS_MAPPING.find((m) => m.id.toLowerCase() === tab.tabId.toLowerCase());
const blockName = tabConfig ? tabConfig.sectionName : tab.tabId;
if (tab.tabId !== 'feature') {
const block = WebImporter.DOMUtils.createTable([[blockName], ['']], document);
main.append(block);
}
if (tab.tabId === 'specification') {

if (tab.tabId === 'specification' && tabConfig.sectionName) {
const attributes = JSON.parse(product.getAttribute('attributes'));
attributeCells.push(['Product Attributes']);
attributeCells.push([tabConfig.sectionName]);
attributes.forEach((attribute) => {
attributeCells.push([attribute.attributeLabel, attribute.attribute]);
});
const attributeTable = WebImporter.DOMUtils.createTable(attributeCells, document);
main.append(attributeTable);
} else if (tabConfig.sectionName) {
const block = WebImporter.DOMUtils.createTable([[tabConfig.sectionName], ['']], document);
main.append(block);
}

if (template.content.childNodes.length > 1) {
Expand Down

0 comments on commit f19e996

Please sign in to comment.