{{- /* hugo-video shortcode /* /* This file is part of hugo-video shortcode. /* A Hugo component shortcode to embed videos using the HTML video element. /* /* @copyright @2019 onwards Nicolas Martignoni (nicolas@martignoni.net) /* @source https://github.com/martignoni/hugo-video /* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later /* */ -}} {{- $video_src := .Get "src" -}} {{- $video_mp4 := "" -}} {{- $video_webm := "" -}} {{- $video_ogg := "" -}} {{- $video_dl := "" -}} {{- $width := "100%" -}} {{- $filenotfound := true -}} {{- $unsupportedfile := true -}} {{- /* Find all files with filename (without suffix) matching "src" parameter. */ -}} {{- $video_files := (.Page.Resources.Match (printf "%s*" $video_src)) -}} {{- /* Find first image file with filename (without suffix) matching "src" parameter. */ -}} {{- $poster := ((.Page.Resources.ByType "image").GetMatch (printf "%s*" $video_src)) -}} {{- /* Find in page bundle all valid video files with matching name. */ -}} {{- with $video_files -}} {{- $filenotfound = false -}} {{- range . -}} {{- if or (in .MediaType.Suffixes "mp4") (in .MediaType.Suffixes "m4v") -}} {{- $unsupportedfile = false -}} {{- $video_mp4 = . -}} {{- end -}} {{- if (in .MediaType.Suffixes "webm") -}} {{- $unsupportedfile = false -}} {{- $video_webm = . -}} {{- end -}} {{- if (in .MediaType.Suffixes "ogv") -}} {{- $unsupportedfile = false -}} {{- $video_ogg = . -}} {{- end -}} {{- end -}} {{- end -}} {{- if $filenotfound -}} {{- /* No file of given name was found, we stop here. */ -}} {{- errorf "No file with filename %q found." $video_src -}} {{- else if $unsupportedfile -}} {{- errorf "No valid video file with filename %q found." $video_src -}} {{- else -}} {{- end -}}