Skip to content

Commit

Permalink
Update quote.js
Browse files Browse the repository at this point in the history
  • Loading branch information
amoghdaryapurkar authored Oct 28, 2024
1 parent bbbf245 commit a4fa9db
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions blocks/quote/quote.js
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
import { createOptimizedPicture } from '../../scripts/aem.js';
import { moveInstrumentation } from '../../scripts/scripts.js';

export default function decorate(block) {
/* change to ul, li */
const ul = document.createElement('ul');
[...block.children].forEach((row) => {
const li = document.createElement('li');
moveInstrumentation(row, li);
while (row.firstElementChild) li.append(row.firstElementChild);
[...li.children].forEach((div) => {
if (div.children.length === 1 && div.querySelector('picture')) div.className = 'cards-card-image';
else div.className = 'cards-card-body';
});
ul.append(li);
});
ul.querySelectorAll('picture > img').forEach((img) => {
const optimizedPic = createOptimizedPicture(img.src, img.alt, false, [{ width: '750' }]);
moveInstrumentation(img, optimizedPic.querySelector('img'));
img.closest('picture').replaceWith(optimizedPic);
});
block.textContent = '';
block.append(ul);
}

0 comments on commit a4fa9db

Please sign in to comment.