add video shortcode (#289)

* add video shortcode

* Use "sampotts/plyr" library instead of "clappr/clappr"

Signed-off-by: hossainemruz <hossainemruz@gmail.com>

Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
This commit is contained in:
David G. Simmons 2021-04-05 15:12:28 -04:00 committed by GitHub
parent d38634df8d
commit 6996894ec1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 5 deletions

View file

@ -0,0 +1,13 @@
{{ $src := .Get "src" }}
{{ $type := .Get "type" }}
{{/*
A page can have multiple videos. We need to generate unique id for them.
Here, we are generating a sequence from 1 to 200 and taking the first element after a shuffle.
This will give a random number in most cases. However, if the page has many videos, we might have a collision.
We should find a better approach for doing this.
*/}}
{{ $randNumber := index (seq 200 | shuffle) 0 }}
<video class="video-player" id="video-{{ $randNumber }}" playsinline controls>
<source src="{{ $src }}" type="{{ $type | default "video/mp4" }}" />
</video>