github.com/neohugo/neohugo@v0.123.8/tpl/tplimpl/embedded/templates/shortcodes/vimeo_simple.html (about) 1 {{- $pc := .Page.Site.Config.Privacy.Vimeo -}} 2 {{- if not $pc.Disable -}} 3 {{- $ctx := dict "page" .Page "pc" $pc "name" .Name "position" .Position }} 4 {{- if .IsNamedParams -}} 5 {{- with .Get "id" -}} 6 {{- $ctx = merge $ctx (dict "id" . "class" ($.Get "class")) -}} 7 {{- template "render-vimeo" $ctx -}} 8 {{- else -}} 9 {{- errorf "The %q shortocde requires a single named parameter, the ID of the Vimeo video. See %s" .Name .Position -}} 10 {{- end -}} 11 {{- else -}} 12 {{- with .Get 0 -}} 13 {{- $ctx = merge $ctx (dict "id" . "class" ($.Get 1)) -}} 14 {{- template "render-vimeo" $ctx -}} 15 {{- else -}} 16 {{- errorf "The %q shortocde requires a single positional parameter, the ID of the Vimeo video. See %s" .Name .Position -}} 17 {{- end -}} 18 {{- end -}} 19 {{- end -}} 20 21 {{- define "render-vimeo" -}} 22 {{- $dnt := cond .pc.EnableDNT 1 0 -}} 23 {{- $url := urls.JoinPath "https://vimeo.com" .id -}} 24 {{- $query := querify "url" $url "dnt" $dnt -}} 25 {{- $request := printf "https://vimeo.com/api/oembed.json?%s" $query -}} 26 {{- with resources.GetRemote $request -}} 27 {{- with .Err -}} 28 {{- errorf "%s" . -}} 29 {{- else -}} 30 {{- with . | transform.Unmarshal -}} 31 {{- $class := printf "%s %s" "s_video_simple" "__h_video" -}} 32 {{- with $.class -}} 33 {{- $class = printf "%s %s" "s_video_simple" . -}} 34 {{- else -}} 35 {{ template "__h_simple_css" $.page }} 36 {{- end -}} 37 {{- $thumbnail := .thumbnail_url -}} 38 {{- $original := $thumbnail | replaceRE "(_.*\\.)" "." -}} 39 <div class="{{ $class }}"> 40 <a href="{{ .provider_url }}{{ .video_id }}" rel="noopener" target="_blank"> 41 <img src="{{ $thumbnail }}" srcset="{{ $thumbnail }} 1x, {{ $original }} 2x" alt="{{ .title }}"> 42 <div class="play"> 43 {{ template "__h_simple_icon_play" $.page }} 44 </div> 45 </a> 46 </div> 47 {{- end -}} 48 {{- end -}} 49 {{- else -}} 50 {{- warnidf "shortcode-vimeo-simple" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}} 51 {{- end -}} 52 {{- end -}}