Skip to content

Commit

Permalink
change the logic: checking URL to matching
Browse files Browse the repository at this point in the history
  • Loading branch information
seanchoi-dev committed Jan 23, 2025
1 parent 8aff28b commit 37715d4
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions libs/blocks/merch-card/merch-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,17 +712,17 @@ export default async function init(el) {
const ctaLinks = ctas.querySelectorAll('a');
ctaLinks.forEach(async (ctaLink) => {
if (!ctaLink.getAttribute('aria-label')) {
if (window.location.pathname.includes('/products/catalog')) {
ctaLink.setAttribute('aria-label', `${ctaLink.textContent} - ${merchCard.querySelector('.card-heading')?.textContent}`);
} else {
const { replaceKey } = await import('../../features/placeholders.js');
ctaLink.addEventListener('mas:resolved', async () => {
const productName = ctaLink.value[0]?.productArrangement?.productFamily;
if (productName) {
await replaceKey(productName, getConfig()).then((label) => ctaLink.setAttribute('aria-label', `${ctaLink.textContent} - ${label} - ${merchCard.querySelector('.card-heading')?.textContent}`));
}
});
}
const { replaceKey } = await import('../../features/placeholders.js');
ctaLink.addEventListener('mas:resolved', async () => {
const productName = ctaLink.value[0]?.productArrangement?.productFamily;
if (productName) {
await replaceKey(productName, getConfig()).then((label) => {
const cardHeading = merchCard.querySelector('.card-heading')?.textContent;
const ariaLabel = label.toLowerCase() === cardHeading.toLowerCase() ? `${ctaLink.textContent} - ${label}` : `${ctaLink.textContent} - ${label} - ${cardHeading}`;
ctaLink.setAttribute('aria-label', ariaLabel);
});
}
});
}
});
}
Expand Down

0 comments on commit 37715d4

Please sign in to comment.