From 0413f934028358d3fd3323a3b5486f01080a5702 Mon Sep 17 00:00:00 2001 From: Julian Bleecker <48663+bleeckerj@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:53:54 -0800 Subject: [PATCH 1/4] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ee6de65..0e917cc 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,11 @@ "lazy" ], "peerDependencies": { - "astro": "^2.0.0 || ^3.0.0-beta || ^4.0.0-beta" + "astro": "^2.0.0 || ^3.0.0-beta || ^4.0.0" }, "homepage": "https://github.com/insin/astro-lazy-youtube-embed#readme", "repository": { "type": "git", "url": "https://github.com/insin/astro-lazy-youtube-embed.git" } -} \ No newline at end of file +} From f264ab7821b8b1d5ea05d54fceaf78f9419abf68 Mon Sep 17 00:00:00 2001 From: Julian Bleecker <48663+bleeckerj@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:54:11 -0800 Subject: [PATCH 2/4] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e917cc..fc415b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "astro-lazy-youtube-embed", - "version": "0.5.1", + "version": "0.5.2", "description": "Embed YouTube videos with a static placeholder which only embeds when you click", "type": "module", "license": "MIT", From bf52c0975495eb89cc965b07e28b78692f32bae4 Mon Sep 17 00:00:00 2001 From: Julian Bleecker <48663+bleeckerj@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:59:24 -0800 Subject: [PATCH 3/4] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fc415b1..2b76ed4 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "lazy" ], "peerDependencies": { - "astro": "^2.0.0 || ^3.0.0-beta || ^4.0.0" + "astro": "^2.0.0 || ^3.0.0-beta || ^4.0.0 || ^5.0.0" }, "homepage": "https://github.com/insin/astro-lazy-youtube-embed#readme", "repository": { From 64bae7c820f64faf9720398c7fea3e27009c87be Mon Sep 17 00:00:00 2001 From: Julian Bleecker <48663+bleeckerj@users.noreply.github.com> Date: Fri, 6 Dec 2024 22:38:13 -0800 Subject: [PATCH 4/4] Added a thing cause I can't be bothered --- YouTubePlaylist.astro | 62 +++++++++++++++++++++++++++++++++++++++++++ index.ts | 1 + package.json | 9 ++++--- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 YouTubePlaylist.astro diff --git a/YouTubePlaylist.astro b/YouTubePlaylist.astro new file mode 100644 index 0000000..4d246b6 --- /dev/null +++ b/YouTubePlaylist.astro @@ -0,0 +1,62 @@ +--- +interface Props extends Omit { + class?: string + cookie?: boolean + embedParams?: Record + loading?: 'eager' | 'lazy' + title: string + videoId?: string // Optional for playlists + list?: string // For playlists +} + +const { + class: className = '', + cookie = false, + embedParams = {}, + loading = 'lazy', + title, + videoId, + list +} = Astro.props as Props; + +// Construct the embed URL +let baseUrl = `https://www.youtube${cookie ? '' : '-nocookie'}.com/embed`; +let embedUrl = list + ? `${baseUrl}/videoseries?list=${list}` + : `${baseUrl}/${videoId}?${new URLSearchParams(embedParams).toString()}`; + +// Decide thumbnail behavior for single videos +let srcdoc = videoId && !list + ? ` + + + ${title} + + + + + ` + : null; // No `srcdoc` for playlists +--- + +
+