generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #626 from hlxsites/625-converter-update-product-menu
625 converter update product menu
- Loading branch information
Showing
5 changed files
with
86 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,45 @@ | ||
const createProductMenu = () => { | ||
// const productMenu = main.querySelector('div.product-menu'); | ||
/* global WebImporter */ | ||
const createProductMenu = (main, document) => { | ||
const productMenus = main.querySelectorAll('div.product-menu'); | ||
[...productMenus].forEach((productMenu) => { | ||
const productMenuEl = productMenu.querySelector('product-menu'); | ||
// eslint-disable-next-line no-undef | ||
const items = JSON.parse(decodeHtmlEntities(productMenuEl.getAttribute('menu-items'))); | ||
const rows = []; | ||
items.forEach((item) => { | ||
const divRight = document.createElement('div'); | ||
const divLeft = document.createElement('div'); | ||
if (item.image) { | ||
const img = document.createElement('img'); | ||
img.src = item.image; | ||
divLeft.append(img); | ||
} | ||
|
||
if (item.title) { | ||
const pEl = document.createElement('p'); | ||
pEl.textContent = item.title; | ||
divLeft.append(pEl); | ||
} | ||
|
||
if (item.fragmentPath) { | ||
const pEL = document.createElement('p'); | ||
pEL.textContent = item.fragmentPath | ||
.replace('content/experience-fragments/danaher/us/en/site', 'fragments') | ||
.replace('/jcr:content', ''); | ||
divRight.append(pEL); | ||
} | ||
rows.push([divLeft, divRight]); | ||
}); | ||
|
||
const cells = [ | ||
['Product Menu'], | ||
...rows, | ||
]; | ||
|
||
if (rows.length > 0) { | ||
const block = WebImporter.DOMUtils.createTable(cells, document); | ||
productMenuEl.append(block); | ||
} | ||
}); | ||
}; | ||
export default createProductMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters