fix: add class to unfurl fallback link to prevent YouTube double-embed
Build & Deploy / build-and-deploy (push) Successful in 1m52s

When unfurl cache is failed/missing for a YouTube URL, renderFallbackLink
returned a classless <a> which matched the youtube-link-to-embed transform
regex (the class exclusion from 819aab1 didn't protect it). This created
one embed from the custom transform and a second from eleventy-plugin-youtube-embed.

Adding class="unfurl-fallback" triggers the (?![^>]*\bclass=) exclusion,
preventing both embeds on like/repost pages with uncached YouTube URLs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
svemagie
2026-04-11 18:45:18 +02:00
parent a236ab8b2d
commit 4db1defaef
+1 -1
View File
@@ -76,7 +76,7 @@ export function escapeHtml(str) {
export function renderFallbackLink(url) {
const domain = escapeHtml(extractDomain(url));
return `<a href="${escapeHtml(url)}" rel="noopener" target="_blank">${domain}</a>`;
return `<a href="${escapeHtml(url)}" rel="noopener" target="_blank" class="unfurl-fallback">${domain}</a>`;
}
export function renderCard(url, metadata) {