diff --git a/index.html b/index.html index 092462a..c39a815 100755 --- a/index.html +++ b/index.html @@ -140,6 +140,64 @@ transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1); } + .yt-video-thumb { + position: relative; + aspect-ratio: 16 / 9; + overflow: hidden; + } + + .yt-video-thumb img { + width: 100%; + height: 100%; + object-fit: cover; + transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1); + } + + .yt-video:hover .yt-video-thumb img { + transform: scale(1.05); + } + + .yt-play-chip { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: center; + background: rgba(2, 6, 23, 0.35); + transition: background 200ms ease; + } + + .yt-video:hover .yt-play-chip { + background: rgba(2, 6, 23, 0.15); + } + + .yt-play-chip svg { + width: 52px; + height: 52px; + color: #ffffff; + filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5)); + transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1); + } + + .yt-video:hover .yt-play-chip svg { + transform: scale(1.1); + } + + .yt-embed { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + border: 0; + } + + .yt-video-title { + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; + } + .nav-scrolled { background: rgba(15, 23, 42, 0.95); box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.2); @@ -1634,6 +1692,15 @@ as they happen.

+
+
+

Latest + videos

+ View all on YouTube +
+
+
@@ -3078,6 +3145,80 @@ }); } + // SOCIAL: latest YouTube uploads from @RobertAbbott-v7o + const YT_CHANNEL_ID = 'UCG_ZDOP21i0Ah26FxiuZmkg'; + // Static snapshot — used only if /api/youtube/latest is unreachable, so the + // section never renders empty. Refresh occasionally as videos are posted. + const YT_FALLBACK_VIDEOS = [ + { id: 'Bw0tDBVo_XI', title: 'GLM 5.2 runs without a graphics card?!', published: '2026-11-04T01:11:20+00:00' }, + { id: 'RyDbc8bQ1o0', title: 'Run GLM 5.2 on a laptop', published: '2026-11-03T01:23:02+00:00' }, + { id: 'GPRSTGsTijo', title: 'Render 1080p AI videos in minutes with Moxiegen Multimedia #comfyui', published: '2026-10-20T07:25:29+00:00' } + ]; + + function ytTimeAgo(iso) { + if (!iso) return ''; + const s = Math.max(0, (Date.now() - new Date(iso).getTime()) / 1000); + const d = Math.floor(s / 86400); + if (d < 1) return 'today'; + if (d === 1) return 'yesterday'; + if (d < 30) return d + ' days ago'; + const m = Math.floor(d / 30); + if (m < 12) return m + (m === 1 ? ' month ago' : ' months ago'); + const y = Math.floor(d / 365); + return y + (y === 1 ? ' year ago' : ' years ago'); + } + + function ytEscape(s) { + return String(s).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); + } + + function renderYtVideos(videos) { + const grid = document.getElementById('ytVideoGrid'); + if (!grid) return; + grid.innerHTML = videos.map(v => { + if (!v || !/^[A-Za-z0-9_-]{11}$/.test(v.id)) return ''; // sanity guard on the id + return ` +
+
+ ${ytEscape(v.title)} + + + +
+
+

${ytEscape(v.title)}

+

${ytTimeAgo(v.published)}

+
+
`; + }).join(''); + } + + function playYtVideo(el, videoId) { + if (!/^[A-Za-z0-9_-]{11}$/.test(videoId)) return; + const thumb = el.classList && el.classList.contains('yt-video-thumb') ? el : el.querySelector('.yt-video-thumb'); + if (!thumb || thumb.querySelector('iframe')) return; + thumb.innerHTML = ``; + } + + async function initYtVideos() { + let videos = YT_FALLBACK_VIDEOS; + try { + const ctrl = new AbortController(); + const timer = setTimeout(() => ctrl.abort(), 6000); + const res = await fetch('/api/youtube/latest', { signal: ctrl.signal }); + clearTimeout(timer); + const json = await res.json(); + if (res.ok && json && json.success && Array.isArray(json.data && json.data.videos) && json.data.videos.length) { + videos = json.data.videos; + } + } catch (err) { /* backend unreachable -> static snapshot */ } + renderYtVideos(videos); + } + window.addEventListener('load', () => { initScrollAnimations(); initBalloon(); @@ -3085,6 +3226,7 @@ initContactForm(); initCopyButtons(); renderHowtoVideos(); + initYtVideos(); });