|
5 | 5 | getAuthoredLinks, |
6 | 6 | normalizePath, |
7 | 7 | resolveArticlesFromIndex, |
| 8 | + isUE, |
8 | 9 | } from '../../scripts/shared.js'; |
9 | 10 |
|
10 | 11 | function buildLinksCard(article) { |
@@ -132,15 +133,28 @@ function decorateDefault(block) { |
132 | 133 |
|
133 | 134 | const linkEl = li.querySelector('.cards-card-image a[href]') || li.querySelector('.cards-card-body a[href]'); |
134 | 135 | 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 | + } |
144 | 158 | } |
145 | 159 |
|
146 | 160 | ul.append(li); |
|
0 commit comments