Skip to content

Commit 99de313

Browse files
committed
custom video block error fixed
1 parent 20317fc commit 99de313

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

blocks/custom/custom.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,27 @@
77
*/
88

99
export default function decorate(block) {
10-
const idCell = block.querySelector('div > div');
11-
if (!idCell) return;
10+
// Get the ID cell (second cell in the first row)
11+
const rows = block.querySelectorAll(':scope > div');
12+
if (rows.length < 1) return;
1213

13-
const videoId = idCell.textContent.trim();
14+
const idRow = rows[0]; // First row contains the ID
15+
const cells = idRow.querySelectorAll(':scope > div');
16+
if (cells.length < 2) return;
17+
18+
const videoId = cells[1].textContent.trim(); // Second cell contains the video ID
1419
if (!videoId) return;
1520

21+
console.log('Loading video ID:', videoId); // Debug log
22+
1623
const iframe = document.createElement('iframe');
17-
iframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1&loop=1&playlist=${videoId}&mute=1&controls=0&rel=0&playsinline=1&disablekb=1`;
18-
iframe.title = 'YouTube Video';
24+
iframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1&start=122&end=156&mute=1&loop=1&playlist=${videoId}&controls=0&rel=0&playsinline=1&modestbranding=1`;
1925
iframe.allow = 'autoplay; encrypted-media';
2026
iframe.allowFullscreen = false;
21-
iframe.setAttribute('tabindex', '-1');
22-
iframe.style = 'border: 0; width: 100%; aspect-ratio: 16/9; pointer-events: none;';
27+
iframe.setAttribute('frameborder', '0');
28+
iframe.style.cssText = 'border: 0; width: 100%; aspect-ratio: 16/9; pointer-events: none;';
2329

30+
// Replace the entire block content
2431
block.innerHTML = '';
2532
block.appendChild(iframe);
2633
}

0 commit comments

Comments
 (0)