From 97f41ba1ccfa7fd940559d52a3e07b6cc87b86fd Mon Sep 17 00:00:00 2001 From: Ramachandra Avuthu Date: Fri, 13 Mar 2026 16:48:24 -0400 Subject: [PATCH] cards with a link UE fix --- blocks/cards/cards.js | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/blocks/cards/cards.js b/blocks/cards/cards.js index 38ee348..3d87e55 100644 --- a/blocks/cards/cards.js +++ b/blocks/cards/cards.js @@ -5,6 +5,7 @@ import { getAuthoredLinks, normalizePath, resolveArticlesFromIndex, + isUE, } from '../../scripts/shared.js'; function buildLinksCard(article) { @@ -132,15 +133,28 @@ function decorateDefault(block) { const linkEl = li.querySelector('.cards-card-image a[href]') || li.querySelector('.cards-card-body a[href]'); if (linkEl) { - const wrapper = createTag('a', { - href: linkEl.getAttribute('href'), - title: linkEl.getAttribute('title')?.trim() || undefined, - class: 'cards-card-link', - }); - while (li.firstChild) wrapper.append(li.firstChild); - li.append(wrapper); - linkEl.replaceWith(...linkEl.childNodes); - li.querySelectorAll('.cards-card-body a[href]').forEach((a) => a.replaceWith(...a.childNodes)); + if (isUE) { + // In UE: use a
wrapper so the authored (with its href) is preserved + const wrapper = createTag('div', { class: 'cards-card-link' }); + while (li.firstChild) wrapper.append(li.firstChild); + li.append(wrapper); + //Remove the button class from the link and button-container class from the parent + const parent = linkEl.parentElement; + if (parent) { + parent.classList.remove('button-container'); + } + linkEl.classList.remove('button'); + } else { + const wrapper = createTag('a', { + href: linkEl.getAttribute('href'), + title: linkEl.getAttribute('title')?.trim() || undefined, + class: 'cards-card-link', + }); + while (li.firstChild) wrapper.append(li.firstChild); + li.append(wrapper); + linkEl.replaceWith(...linkEl.childNodes); + li.querySelectorAll('.cards-card-body a[href]').forEach((a) => a.replaceWith(...a.childNodes)); + } } ul.append(li);