From 097abc3cda0d9a6f3cfedfa3c6351648efd8d6b8 Mon Sep 17 00:00:00 2001
From: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 11 Mar 2024 20:41:48 +0000
Subject: [PATCH] chore(deps): bump async-mutex from 0.4.1 to 0.5.0 (#991)
---
quartz/plugins/transformers/ofm.ts | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/quartz/plugins/transformers/ofm.ts b/quartz/plugins/transformers/ofm.ts
index 237d683..5058c8b 100644
--- a/quartz/plugins/transformers/ofm.ts
+++ b/quartz/plugins/transformers/ofm.ts
@@ -123,6 +123,7 @@
)
const blockReferenceRegex = new RegExp(/\^([-_A-Za-z0-9]+)$/, "g")
const ytLinkRegex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
+const ytPlaylistLinkRegex = /[?&]list=([^#?&]*)/
const videoExtensionRegex = new RegExp(/\.(mp4|webm|ogg|avi|mov|flv|wmv|mkv|mpg|mpeg|3gp|m4v)$/)
const wikilinkImageEmbedRegex = new RegExp(
/^(?<alt>(?!^\d*x?\d*$).*?)?(\|?\s*?(?<width>\d+)(x(?<height>\d+))?)?$/,
@@ -327,7 +328,7 @@
children: [
{
type: "text",
- value: `#${tag}`,
+ value: tag,
},
],
}
@@ -574,7 +575,9 @@
if (node.tagName === "img" && typeof node.properties.src === "string") {
const match = node.properties.src.match(ytLinkRegex)
const videoId = match && match[2].length == 11 ? match[2] : null
+ const playlistId = node.properties.src.match(ytPlaylistLinkRegex)?.[1]
if (videoId) {
+ // YouTube video (with optional playlist)
node.tagName = "iframe"
node.properties = {
class: "external-embed",
@@ -582,7 +585,20 @@
frameborder: 0,
width: "600px",
height: "350px",
- src: `https://www.youtube.com/embed/${videoId}`,
+ src: playlistId
+ ? `https://www.youtube.com/embed/${videoId}?list=${playlistId}`
+ : `https://www.youtube.com/embed/${videoId}`,
+ }
+ } else if (playlistId) {
+ // YouTube playlist only.
+ node.tagName = "iframe"
+ node.properties = {
+ class: "external-embed",
+ allow: "fullscreen",
+ frameborder: 0,
+ width: "600px",
+ height: "350px",
+ src: `https://www.youtube.com/embed/videoseries?list=${playlistId}`,
}
}
}
--
Gitblit v1.10.0