{{- /* hugo-video shortcode /* /* This file is part of hugo-video shortcode. /* A Hugo component shortcode to embed videos using the HTML video element. /* /* @source https://github.com/martignoni/hugo-video /* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later /* */ -}} {{- $video_src := or (.Get "src") (.Get 0) -}} {{/* */}} {{- $video_mp4 := "" -}} {{- $video_webm := "" -}} {{- $video_ogg := "" -}} {{- $video_dl := "" -}} {{- $width := .Get 1 | default "100%" }} {{- $filenotfound := true -}} {{- $unsupportedfile := true -}} {{- /* Find in page bundle all valid video files with matching name. */ -}} {{- with $video_src -}} {{- $filenotfound = false -}} {{- if or (strings.HasSuffix . "mp4") (strings.HasSuffix . "m4v") -}} {{- $unsupportedfile = false -}} {{- $video_mp4 = . -}} {{- end -}} {{- if (strings.HasSuffix . "webm") -}} {{- $unsupportedfile = false -}} {{- $video_webm = . -}} {{- end -}} {{- if (strings.HasSuffix . "ogv") -}} {{- $unsupportedfile = false -}} {{- $video_ogg = . -}} {{- end -}} {{- end -}} {{- if $filenotfound -}} {{- /* No file of given name was found, we stop here. */ -}} {{- errorf "No file with filename %v found." $video_src -}} {{- else if $unsupportedfile -}} {{- errorf "No valid video file with filename %v found." $video_src -}} {{- else -}} {{- end -}}