2023-04-17 12:10:22 +02:00
|
|
|
export async function renderAsciicast() {
|
2023-01-18 01:46:58 +01:00
|
|
|
const els = document.querySelectorAll('.asciinema-player-container');
|
|
|
|
if (!els.length) return;
|
|
|
|
|
2023-01-18 19:19:38 +01:00
|
|
|
const [player] = await Promise.all([
|
2025-01-22 08:11:51 +01:00
|
|
|
// @ts-expect-error: module exports no types
|
2023-01-18 19:19:38 +01:00
|
|
|
import(/* webpackChunkName: "asciinema-player" */'asciinema-player'),
|
|
|
|
import(/* webpackChunkName: "asciinema-player" */'asciinema-player/dist/bundle/asciinema-player.css'),
|
|
|
|
]);
|
2023-01-18 01:46:58 +01:00
|
|
|
|
|
|
|
for (const el of els) {
|
|
|
|
player.create(el.getAttribute('data-asciinema-player-src'), el, {
|
|
|
|
// poster (a preview frame) to display until the playback is started.
|
|
|
|
// Set it to 1 hour (also means the end if the video is shorter) to make the preview frame show more.
|
|
|
|
poster: 'npt:1:0:0',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|