35 lines
1.5 KiB
HTML

{{- $href := (.Get 0) -}}
{{- $type := (.Get 1) -}}
{{- $data := (.Get 2) -}}
{{- $link := false -}}
{{- if not $type -}}
{{- $type = "embed" -}}
{{- end -}}
{{- $iswindow := (in (slice "app" "window") $type) -}}
<figure class="w-100" style="margin: auto; {{ $data | safeCSS }} height: auto;">
{{- if (eq $type "embed") -}}
{{- $link = $href -}}
<iframe class="w-100 vh-75" src="{{ $href }}" allowfullscreen="allowfullscreen"></iframe>
{{- else if $iswindow -}}
<figcaption style="background: #330066; padding: 0.25em; border: 4px solid #330066;">{{ partial "anchor.html" (dict "Params" (dict
"style" "color: rgba(255,255,255,.9); text-decoration: none;"
"target" "_blank"
"rel" "noopener"
"href" $href)) }}</figcaption>
<div class="vh-75" style="resize: vertical; overflow: hidden; border: 4px solid #330066; {{ $data | safeCSS }}">
<iframe class="w-100 h-100 bn" src="{{ $href }}" allowfullscreen="allowfullscreen" onload="this.focus()"></iframe>
</div>
{{- else if in (slice "youtube" "yt") $type -}}
{{- $link = (printf "https://youtu.be/%s" $href) -}}
{{- $ratio := (split $data ":") -}}
<iframe class="YouTube" src="https://www.youtube-nocookie.com/embed/{{ $href }}" allowfullscreen="allowfullscreen"
style="height: calc(100vh / {{ index $ratio 0 }} * {{ index $ratio 1 }});"></iframe>
{{- end -}}
{{- if not $iswindow -}}
<figcaption>{{ partial "anchor.html" (dict "Params" (dict
"target" "_blank"
"rel" "noopener"
"href" $link)) }}</figcaption>
{{- end -}}
</figure>