@terrymooreii/sia 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/content.js +24 -21
- package/package.json +1 -1
package/lib/content.js
CHANGED
|
@@ -221,28 +221,31 @@ function embedGiphyGifs(html) {
|
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
// Override the link renderer to handle YouTube URLs
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
224
|
+
// Override the link renderer to handle YouTube and Giphy URLs
|
|
225
|
+
marked.use({
|
|
226
|
+
renderer: {
|
|
227
|
+
link(token) {
|
|
228
|
+
const videoId = extractYouTubeId(token.href);
|
|
229
|
+
|
|
230
|
+
if (videoId) {
|
|
231
|
+
// Return responsive YouTube embed instead of a link
|
|
232
|
+
return `<div class="youtube-embed"><iframe src="https://www.youtube.com/embed/${videoId}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const gifId = extractGiphyId(token.href);
|
|
236
|
+
|
|
237
|
+
if (gifId) {
|
|
238
|
+
// Return responsive Giphy embed instead of a link
|
|
239
|
+
return `<div class="giphy-embed"><iframe src="https://giphy.com/embed/${gifId}" frameBorder="0" class="giphy-embed" allowFullScreen></iframe></div>`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Use default link rendering for non-YouTube/Giphy links
|
|
243
|
+
const text = token.text || token.href;
|
|
244
|
+
const title = token.title ? ` title="${token.title}"` : '';
|
|
245
|
+
return `<a href="${token.href}"${title}>${text}</a>`;
|
|
246
|
+
}
|
|
241
247
|
}
|
|
242
|
-
|
|
243
|
-
// Use default link rendering for non-YouTube/Giphy links
|
|
244
|
-
return originalLink(token);
|
|
245
|
-
};
|
|
248
|
+
});
|
|
246
249
|
|
|
247
250
|
/**
|
|
248
251
|
* Generate a URL-friendly slug from a string
|