{{/* Get parameters from shortcode call. */}} {{ $host := "" }} {{ $id := "" }} {{ if .IsNamedParams -}} {{ $host = (.Get "host") }} {{ $id = (.Get "id") }} {{- else -}} {{ $host = (.Get 0) }} {{ $id = (.Get 1) }} {{- end }} {{/* Fetch a local copy of the videos preview image. */}} {{ $videoinfo := dict }} {{ $path := path.Join $host "api" "v1" "videos" $id }} {{ $endpoint := print "https://" $path }} {{ with resources.GetRemote $endpoint }} {{ with .Err }} {{ errorf "%s" . }} {{ else }} {{ $videoinfo = . | transform.Unmarshal }} {{ end }} {{ else }} {{ errorf "Unable to get remote resource %q" $endpoint }} {{ end }} {{ $url := print "https://" $host $videoinfo.previewPath }} {{ $img := resources.GetRemote $url }} {{ $destination := path.Join (.Page.RelPermalink) (print $id ".jpg") }} {{ $img := $img.Content | resources.FromString $destination }} {{ $img := $img.RelPermalink }} {{/* Generate the videos embed url. */}} {{ $path := path.Join $host "videos" "embed" $id }} {{ $url := print "https://" $path }} {{/* Fetch the videos title via the peertube api. */}} {{ $title := $videoinfo.name }}