| 1 |
{{- /* |
| 2 |
Renders an embedded Vimeo video. |
| 3 |
|
| 4 |
Accepts named or positional arguments. If positional, order is id, class, |
| 5 |
title, then loading. |
| 6 |
|
| 7 |
@param {bool} [allowFullScreen=true] Whether the iframe element can activate full screen mode. |
| 8 |
@param {string} [class] The class attribute of the wrapping div element. When specified, removes the style attributes from the iframe element and its wrapping div element. |
| 9 |
@param {string} [id] The video id. Optional if the id is the first and only positional argument. |
| 10 |
@param {string} [loading=eager] The loading attribute of the iframe element. |
| 11 |
@param {string} [title=Vimeo video] The title attribute of the iframe element. |
| 12 |
|
| 13 |
@returns {template.HTML} |
| 14 |
|
| 15 |
@example {{< vimeo 19899678 >}} |
| 16 |
@example {{< vimeo id=19899678 class="foo bar" loading=lazy title="My Video" >}} |
| 17 |
*/}} |
| 18 |
{{- $pc := site.Config.Privacy.Vimeo }} |
| 19 |
{{- if not $pc.Disable }} |
| 20 |
{{- if $pc.Simple }} |
| 21 |
{{- template "_shortcodes/vimeo_simple.html" . }} |
| 22 |
{{- else }} |
| 23 |
{{- $dnt := cond $pc.EnableDNT 1 0 }} |
| 24 |
|
| 25 |
{{- $allowFullScreen := true }} |
| 26 |
{{- $class := or (.Get "class") }} |
| 27 |
{{- $id := or (.Get "id") (.Get 0) }} |
| 28 |
{{- $loading := or (.Get "loading") }} |
| 29 |
{{- $title := or (.Get "title") }} |
| 30 |
|
| 31 |
{{- if in (slice "true" true 1) (.Get "allowFullScreen") }} |
| 32 |
{{- $allowFullScreen = true }} |
| 33 |
{{- else if in (slice "false" false 0) (.Get "allowFullScreen") }} |
| 34 |
{{- $allowFullScreen = false }} |
| 35 |
{{- end }} |
| 36 |
|
| 37 |
{{- $iframeAllowList := "" }} |
| 38 |
{{- if $allowFullScreen }} |
| 39 |
{{- $iframeAllowList = "fullscreen" }} |
| 40 |
{{- end }} |
| 41 |
|
| 42 |
{{- $divStyle := "position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;" }} |
| 43 |
{{- $iframeStyle := "position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" }} |
| 44 |
|
| 45 |
{{- with $id }} |
| 46 |
{{- $src := printf "https://player.vimeo.com/video/%v?dnt=%v" . $dnt }} |
| 47 |
<div |
| 48 |
{{- with $class }} |
| 49 |
class="{{ . }}" |
| 50 |
{{- else }} |
| 51 |
style="{{ $divStyle | safeCSS }}" |
| 52 |
{{- end }}> |
| 53 |
<iframe |
| 54 |
src="{{- $src }}" |
| 55 |
{{- if not $class }} |
| 56 |
style="{{ $iframeStyle | safeCSS }}" |
| 57 |
{{- end }} |
| 58 |
{{- with $iframeAllowList }} allow="{{ . }}" {{- end }} |
| 59 |
{{- with $loading }} loading="{{ . }}" {{- end }} |
| 60 |
{{- with $title }} title="{{ . }}" {{- end }}> |
| 61 |
</iframe> |
| 62 |
</div> |
| 63 |
{{- else }} |
| 64 |
{{- errorf "The %q shortcode requires a video id, either as the first positional argument or an argument named id. See %s" .Name .Position }} |
| 65 |
{{- end }} |
| 66 |
{{- end }} |
| 67 |
{{- end }} |