Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
catalan-adobe committed Aug 12, 2024
1 parent 726ac3f commit 60146b1
Showing 1 changed file with 0 additions and 105 deletions.
105 changes: 0 additions & 105 deletions js/sections-mapping/import/sections-mapping.import.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,111 +284,6 @@ export default {

return importedEl;
});
/**
* init elements
*/

// const main = document.querySelector('main') || document.body;
// const headerEl = document.createElement('div');
// const footerEl = document.createElement('div');
// const importedElements = [];

// /**
// * parse sections mapping data
// */

// const importedContent = document.createElement('div');

// // get dom element from xpath string
// const elementsToParse = mapping.map((m) => getElementByXpath(document, m.xpath) || null);

// mapping.forEach((m, idx) => {
// // get dom element from xpath string
// const el = elementsToParse[idx];
// if (el) {
// console.log('found element', m.section, el);
// if (m.mapping === 'header') {
// const block = parsers.header(el, window);
// if (block) {
// headerEl.appendChild(block);
// }
// } else if (m.mapping === 'footer') {
// const block = parsers.footer(el, window);
// if (block) {
// footerEl.appendChild(block);
// }
// } else {
// const parser = parsers[m.mapping];
// if (parser) {
// const block = parser(el, window);
// if (block) {
// importedContent.appendChild(block);
// }
// } else {
// console.warn('parser not found', m.mapping);
// }
// }
// } else {
// console.warn('element not found', m.section, m.xpath);
// }
// });

// /**
// * cleanup to remove unwanted elements
// */

// // adjust anchor links (https://github.com/adobe/helix-importer/issues/348)
// if (main.querySelector('a[href^="#"]')) {
// const u = new URL(params.originalURL);
// const links = main.querySelectorAll('a[href^="#"]');
// for (let i = 0; i < links.length; i += 1) {
// const a = links[i];
// a.href = `${u.pathname}${a.getAttribute('href')}`;
// }
// }

// // hidden elements
// main.querySelectorAll('[data-hlx-imp-hidden-div]').forEach((el) => { el.remove(); });

// WebImporter.DOMUtils.remove(main, [
// 'style',
// 'source',
// 'script',
// ]);

// main.querySelectorAll('div').forEach((el) => {
// Object.keys(el.dataset).forEach((key) => delete el.dataset[key]);
// for (let i = 0; i < el.attributes.length; i += 1) {
// el.removeAttribute(el.attributes[i].name);
// }
// });

/**
* return + custom report
*/

// // make every report value a string
// Object.keys(IMPORT_REPORT).map(k => (IMPORT_REPORT[k] = '' + IMPORT_REPORT[k]));

// importedElements.push({
// element: importedContent,
// path: generateDocumentPath({ document, url: params.originalURL }),
// report: IMPORT_REPORT,
// });

// if (headerEl.children.length > 0) {
// importedElements.push({
// element: headerEl,
// path: '/nav',
// });
// }

// if (footerEl.children.length > 0) {
// importedElements.push({
// element: footerEl,
// path: '/footer',
// });
// }

return importedElements;
},
Expand Down

0 comments on commit 60146b1

Please sign in to comment.