aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/shortcodes/youtube.html
blob: 9ec1cfbfb3e1188e931a7665f508d587be1e9d5b (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
29
30
31
32
33
{{- $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)) -}}

{{- $url := "www.youtube-nocookie.com" -}}
{{- $controls := "?controls=1" -}}

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

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

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