diff options
Diffstat (limited to 'themes/default/layouts/shortcodes/youtube.html')
-rw-r--r-- | themes/default/layouts/shortcodes/youtube.html | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/themes/default/layouts/shortcodes/youtube.html b/themes/default/layouts/shortcodes/youtube.html new file mode 100644 index 0000000..791e3da --- /dev/null +++ b/themes/default/layouts/shortcodes/youtube.html @@ -0,0 +1,29 @@ +{{- $url := "www.youtube-nocookie.com" -}} +{{- $id := default "aqz-KE-bpKQ" (.Get "id" | default (.Get 0)) -}} +{{- $title := default "YouTube Video" (.Get "title" | default (.Get 1)) -}} +{{- $start := default "" (.Get "start" | default (.Get 2)) -}} +{{- $end := default "" (.Get "end" | default (.Get 3)) -}} +{{- $muted := default "" (.Get "muted" | default (.Get 4)) -}} + +{{- if (and $start $end) -}} + {{ $start = print "&start=" $start }} + {{ $end = print "&end=" $end }} +{{- end -}} + +{{- if $muted -}} + {{ $muted = "&mute=1" }} +{{- end -}} + +<youtube-video> + <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"> + <iframe loading="lazy" sandbox="allow-scripts allow-same-origin" + src="https://{{ $url }}/embed/{{ $id }}{{ "?controls=1" }}{{ $start }}{{ $end }}{{ $muted }}" + style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" + allowfullscreen title="{{ $title }}"> + </iframe> + </div> + <figcaption> + {{ $title | markdownify }}: + {{ print "[Link](https://www.youtube.com/watch?v=" $id ")" | markdownify }} + </figcaption> +</youtube-video> |