From 0243c7ab789a0c508b1e8ab8378cdba69a37471d Mon Sep 17 00:00:00 2001 From: Mark McConnell Date: Fri, 3 May 2024 05:07:04 -0400 Subject: [PATCH] - Adjusts X links to Twitter in order to embed - X has yet to release update documentation --- blocks/embed/embed.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/blocks/embed/embed.js b/blocks/embed/embed.js index c362fac6..296c1ecd 100644 --- a/blocks/embed/embed.js +++ b/blocks/embed/embed.js @@ -27,6 +27,12 @@ function buildTwitterEmbed(url) { return `
`; } +function buildXEmbed(url) { + const newUrl = new URL(url); + newUrl.hostname = 'twitter.com'; + return buildTwitterEmbed(newUrl); +} + function buildInstagramEmbed(url) { const endingSlash = url.pathname.endsWith('/') ? '' : '/'; const location = window.location.href.endsWith('.html') ? window.location.href : `${window.location.href}.html`; @@ -85,6 +91,8 @@ function loadEmbed(block) { a.outerHTML = buildYoutubeEmbed(url); } else if (hostname.includes('twitter')) { a.outerHTML = buildTwitterEmbed(url); + } else if (hostname === ('x.com')) { + a.outerHTML = buildXEmbed(url); } else if (hostname.includes('instagram')) { a.outerHTML = buildInstagramEmbed(url); } else if (hostname.includes('facebook')) {