From 6ea858a505f3a7bc1d37da26c341c46b0ab19aa9 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 15 May 2021 21:21:32 -0500 Subject: [PATCH] Leave out timestamps container for 0 timestamps --- components-eleventy/video/player.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/components-eleventy/video/player.js b/components-eleventy/video/player.js index 6492630..ebadb86 100644 --- a/components-eleventy/video/player.js +++ b/components-eleventy/video/player.js @@ -1,6 +1,9 @@ import renderPoster from './poster.js' function renderTimestamps ( video ) { + + if ( video.timestamps.length > 0 ) return '' + const timestampsForRender = video.timestamps.map( timestamp => { const [ minutes, seconds ] = timestamp.time.split(':') @@ -10,13 +13,21 @@ function renderTimestamps ( video ) { } }) - return timestampsForRender.map( timestamp => (/* html */` + const timestampButtonsHtml = timestampsForRender.map( timestamp => (/* html */` `) ).join('') + + return /* html */` +
+
+ ${ timestampButtonsHtml } +
+
+ ` } export default async function ( video, options = {} ) { @@ -66,11 +77,9 @@ export default async function ( video, options = {} ) { -
-
- ${ timestampsHtml } -
-
+ + ${ timestampsHtml } + ` }