aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/shortcodes/youtube.html
blob: 99612edd796368ca73bf31876766cb724110e54f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{{- $url := "www.youtube-nocookie.com" -}}
{{- $id       := default "aqz-KE-bpKQ"   (.Get "id"       | default (.Get 0)) -}}
{{- $title    := default "YouTube Video" (.Get "title"    | default (.Get 1)) -}}
{{- $start    := default ""              (.Get "start"    | default (.Get 2)) -}}
{{- $end      := default ""              (.Get "end"      | default (.Get 3)) -}}
{{- $muted    := default ""              (.Get "muted"    | default (.Get 4)) -}}

{{- if (and $start $end) -}}
  {{ $start = print "&start=" $start }}
  {{ $end   = print "&end=" $end }}
{{- end -}}

{{- if $muted -}}
  {{ $muted = "&mute=1" }}
{{- end -}}

<youtube-video>
  <iframe loading="lazy"
    height="300"
    sandbox="allow-scripts allow-same-origin"
    src="https://{{ $url }}/embed/{{ $id }}{{ "?controls=1" }}{{ $start }}{{ $end }}{{ $muted }}"
    allowfullscreen title="{{ $title }}">
  </iframe>
  <footer>
    {{ $title | markdownify }}
    ({{ print "[Link](https://www.youtube.com/watch?v=" $id ")" | markdownify }})
  </footer>
</youtube-video>