Skip to content

Commit 97f41ba

Browse files
committed
cards with a link UE fix
1 parent a7f69d2 commit 97f41ba

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

blocks/cards/cards.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getAuthoredLinks,
66
normalizePath,
77
resolveArticlesFromIndex,
8+
isUE,
89
} from '../../scripts/shared.js';
910

1011
function buildLinksCard(article) {
@@ -132,15 +133,28 @@ function decorateDefault(block) {
132133

133134
const linkEl = li.querySelector('.cards-card-image a[href]') || li.querySelector('.cards-card-body a[href]');
134135
if (linkEl) {
135-
const wrapper = createTag('a', {
136-
href: linkEl.getAttribute('href'),
137-
title: linkEl.getAttribute('title')?.trim() || undefined,
138-
class: 'cards-card-link',
139-
});
140-
while (li.firstChild) wrapper.append(li.firstChild);
141-
li.append(wrapper);
142-
linkEl.replaceWith(...linkEl.childNodes);
143-
li.querySelectorAll('.cards-card-body a[href]').forEach((a) => a.replaceWith(...a.childNodes));
136+
if (isUE) {
137+
// In UE: use a <div> wrapper so the authored <a> (with its href) is preserved
138+
const wrapper = createTag('div', { class: 'cards-card-link' });
139+
while (li.firstChild) wrapper.append(li.firstChild);
140+
li.append(wrapper);
141+
//Remove the button class from the link and button-container class from the parent
142+
const parent = linkEl.parentElement;
143+
if (parent) {
144+
parent.classList.remove('button-container');
145+
}
146+
linkEl.classList.remove('button');
147+
} else {
148+
const wrapper = createTag('a', {
149+
href: linkEl.getAttribute('href'),
150+
title: linkEl.getAttribute('title')?.trim() || undefined,
151+
class: 'cards-card-link',
152+
});
153+
while (li.firstChild) wrapper.append(li.firstChild);
154+
li.append(wrapper);
155+
linkEl.replaceWith(...linkEl.childNodes);
156+
li.querySelectorAll('.cards-card-body a[href]').forEach((a) => a.replaceWith(...a.childNodes));
157+
}
144158
}
145159

146160
ul.append(li);

0 commit comments

Comments
 (0)