Skip to content

Commit 7fa8dd3

Browse files
HeyItsGilbertclaude
andcommitted
feat(podcast): render YouTube thumbnails and click-to-load embed
List cards and episode pages hotlink the YouTube thumbnail (maxresdefault, onerror fallback to hqdefault) when an episode has a `youtube` id, falling back to the existing purple icon otherwise. The single page adds a click-to-load embed facade (thumbnail poster -> youtube-nocookie iframe on click) alongside the existing audio player, avoiding eager iframes across 220 episodes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 50f5d35 commit 7fa8dd3

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

themes/powershell-community/layouts/_default/single.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,27 @@ <h3 class="font-semibold text-gray-900">Listen to this Episode</h3>
9999
</div>
100100
{{ end }}
101101

102+
<!-- YouTube embed (click-to-load facade) -->
103+
{{ if and (eq .Section "podcast") .Params.youtube }}
104+
{{ with .Params.youtube }}
105+
<div class="mb-8">
106+
<div id="yt-facade" data-id="{{ . }}"
107+
role="button" tabindex="0" aria-label="Play video on YouTube"
108+
class="relative aspect-video rounded-xl overflow-hidden cursor-pointer group bg-black">
109+
<img src="https://img.youtube.com/vi/{{ . }}/maxresdefault.jpg"
110+
onerror="this.onerror=null;this.src='https://img.youtube.com/vi/{{ . }}/hqdefault.jpg';"
111+
alt="Watch this episode on YouTube" loading="lazy"
112+
class="w-full h-full object-cover">
113+
<div class="absolute inset-0 flex items-center justify-center bg-black/20 group-hover:bg-black/30 transition-colors duration-200">
114+
<div class="w-20 h-20 bg-red-600 rounded-2xl flex items-center justify-center shadow-lg group-hover:scale-110 transition-transform duration-200">
115+
<i class="fas fa-play text-white text-3xl ml-1"></i>
116+
</div>
117+
</div>
118+
</div>
119+
</div>
120+
{{ end }}
121+
{{ end }}
122+
102123
<!-- Article Content -->
103124
<div class="prose" style="max-width: none; font-size: 1.125rem;">
104125
{{ .Content }}
@@ -197,5 +218,26 @@ <h4 class="text-lg font-semibold text-gray-900 mb-3 line-clamp-2">
197218
}
198219
});
199220
});
221+
222+
// Click-to-load YouTube embed facade (avoids eager iframe load)
223+
(function () {
224+
const facade = document.getElementById('yt-facade');
225+
if (!facade) return;
226+
function loadEmbed() {
227+
const id = facade.dataset.id;
228+
const iframe = document.createElement('iframe');
229+
iframe.src = 'https://www.youtube-nocookie.com/embed/' + id + '?autoplay=1';
230+
iframe.title = 'YouTube video player';
231+
iframe.allow = 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share';
232+
iframe.allowFullscreen = true;
233+
iframe.className = 'absolute inset-0 w-full h-full';
234+
facade.innerHTML = '';
235+
facade.appendChild(iframe);
236+
}
237+
facade.addEventListener('click', loadEmbed);
238+
facade.addEventListener('keydown', function (e) {
239+
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); loadEmbed(); }
240+
});
241+
})();
200242
</script>
201243
{{ end }}

themes/powershell-community/layouts/podcast/list.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,19 @@ <h1 class="text-4xl lg:text-5xl font-bold mb-2">{{ .Site.Params.podcast.title }}
3333
<article class="bg-white rounded-xl shadow-md hover:shadow-lg transition-shadow duration-300 overflow-hidden podcast-episode" data-title="{{ .Title | lower }}" data-content="{{ .Summary | lower }}">
3434
<div class="lg:flex">
3535
<div class="lg:w-1/3 p-6 lg:pr-0">
36+
{{ $title := .Title }}
37+
{{ with .Params.youtube }}
38+
<div class="aspect-square rounded-lg overflow-hidden mb-4 lg:mb-0 bg-gray-900">
39+
<img src="https://img.youtube.com/vi/{{ . }}/maxresdefault.jpg"
40+
onerror="this.onerror=null;this.src='https://img.youtube.com/vi/{{ . }}/hqdefault.jpg';"
41+
alt="{{ $title }}" loading="lazy"
42+
class="w-full h-full object-cover">
43+
</div>
44+
{{ else }}
3645
<div class="aspect-square bg-gradient-to-br from-purple-400 to-purple-600 rounded-lg flex items-center justify-center mb-4 lg:mb-0">
3746
<i class="fas fa-podcast text-4xl text-white"></i>
3847
</div>
48+
{{ end }}
3949
</div>
4050
<div class="lg:w-2/3 p-6 lg:pl-8">
4151
<div class="flex items-center text-purple-600 text-sm font-medium mb-3">

0 commit comments

Comments
 (0)