Skip to content

Commit d2487be

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 fcef46a commit d2487be

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
@@ -97,6 +97,27 @@ <h3 class="font-semibold text-gray-900">Listen to this Episode</h3>
9797
</audio>
9898
</div>
9999
{{ end }}
100+
101+
<!-- YouTube embed (click-to-load facade) -->
102+
{{ if and (eq .Section "podcast") .Params.youtube }}
103+
{{ with .Params.youtube }}
104+
<div class="mb-8">
105+
<div id="yt-facade" data-id="{{ . }}"
106+
role="button" tabindex="0" aria-label="Play video on YouTube"
107+
class="relative aspect-video rounded-xl overflow-hidden cursor-pointer group bg-black">
108+
<img src="https://img.youtube.com/vi/{{ . }}/maxresdefault.jpg"
109+
onerror="this.onerror=null;this.src='https://img.youtube.com/vi/{{ . }}/hqdefault.jpg';"
110+
alt="Watch this episode on YouTube" loading="lazy"
111+
class="w-full h-full object-cover">
112+
<div class="absolute inset-0 flex items-center justify-center bg-black/20 group-hover:bg-black/30 transition-colors duration-200">
113+
<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">
114+
<i class="fas fa-play text-white text-3xl ml-1"></i>
115+
</div>
116+
</div>
117+
</div>
118+
</div>
119+
{{ end }}
120+
{{ end }}
100121

101122
<!-- Article Content -->
102123
<div class="prose" style="max-width: none; font-size: 1.125rem;">
@@ -191,5 +212,26 @@ <h4 class="text-lg font-semibold text-gray-900 mb-3 line-clamp-2">
191212
}
192213
});
193214
});
215+
216+
// Click-to-load YouTube embed facade (avoids eager iframe load)
217+
(function () {
218+
const facade = document.getElementById('yt-facade');
219+
if (!facade) return;
220+
function loadEmbed() {
221+
const id = facade.dataset.id;
222+
const iframe = document.createElement('iframe');
223+
iframe.src = 'https://www.youtube-nocookie.com/embed/' + id + '?autoplay=1';
224+
iframe.title = 'YouTube video player';
225+
iframe.allow = 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share';
226+
iframe.allowFullscreen = true;
227+
iframe.className = 'absolute inset-0 w-full h-full';
228+
facade.innerHTML = '';
229+
facade.appendChild(iframe);
230+
}
231+
facade.addEventListener('click', loadEmbed);
232+
facade.addEventListener('keydown', function (e) {
233+
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); loadEmbed(); }
234+
});
235+
})();
194236
</script>
195237
{{ 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)