blob: 1e2645d7533e2e1a72cf8712aff6fcbc3051f14c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
{{- $src := .Get "src" -}}
{{- $id := .Get "id" -}}
{{- $title := .Get "title" | default "Video" -}}
{{- $class := .Get "class" | default "" -}}
{{- if $id -}}
<div class="my-6{{- with $class }} {{ . }}{{- end -}}">
<iframe
class="w-full aspect-video"
src="https://www.youtube.com/embed/{{ $id }}"
title="{{ $title }}"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
></iframe>
</div>
{{- else if $src -}}
{{- $ext := $src | path.Ext -}}
{{- $filetype := slicestr $ext 1 -}}
{{- $videoURL := $src -}}
{{- $resource := .Page.Resources.GetMatch $src -}}
{{- if $resource -}}{{- $videoURL = $resource.RelPermalink -}}{{- end -}}
<video
{{- with $class }} class="{{ . }}"{{ end }}
controls
preload="auto"
playsinline
{{- with .Get "width" }} width="{{ . }}"{{ end }}
{{- with .Get "height" }} height="{{ . }}"{{ end }}
{{- if eq (.Get "autoplay") "true" }} autoplay{{ end }}
{{- if eq (.Get "loop") "true" }} loop{{ end }}
{{- if eq (.Get "muted") "true" }} muted{{ end }}
>
<source src="{{ $videoURL }}" type="video/{{ $filetype }}">
</video>
{{- else -}}
{{- errorf "video shortcode: either 'src' or 'id' parameter is required" -}}
{{- end -}}
|