Create main parts of short codes

This commit is contained in:
2023-10-25 14:38:54 +02:00
parent e15b181a99
commit 71c823a653
10 changed files with 209 additions and 17 deletions

View File

@@ -0,0 +1,27 @@
{{ $cols := .Parent.Get "columns" }}
{{ $imgOriginal := .Page.Resources.GetMatch (.Get "src") }}
{{ $img := $imgOriginal }}
{{ if eq $cols "2" }}
{{ $img = $imgOriginal.Fit "500x1000 webp" }}
{{ else if eq $cols "3" }}
{{ $img = $imgOriginal.Fit "333x800 webp" }}
{{ else if eq $cols "4" }}
{{ $img = $imgOriginal.Fit "250x500 webp" }}
{{ else }}
{{ $img = $imgOriginal.Fit "800x1000 webp" }}
{{ end }}
{{ $imgFitted := $imgOriginal.Fit "850x1000 webp" }}
<figure class="tsc-gallery-img">
<a
{{ with .Get "href" }}
href="{{ . }}"
{{ else }}
data-url="{{ $imgFitted.RelPermalink }}"
{{ end }}
>
<img
{{ with .Get "alt"}}alt="{{.}}"{{ end }}
src="{{ $img.RelPermalink }}"
>
</a>
</figure>

View File

@@ -1 +1,7 @@
{{ .Inner }}
{{ $colClass := "" }}
{{- with .Get "columns" }}
{{ $colClass = (print "cols-" .) }}
{{ end -}}
<div class="tsc-gallery {{ $colClass }}">
{{ .Inner }}
</div>

View File

@@ -0,0 +1,19 @@
<figure>
{{ with .Get "href" }}
<a href="{{ . }}">
{{ end }}
<img
{{- with .Get "alt" }}alt="{{ . }}"{{ end }}
{{- $filename := .Get "src" }}
{{ $resource := .Page.Resources.Get $filename -}}
src="{{ $resource.RelPermalink }}"
>
{{ with .Get "href" }}
</a>
{{ end }}
{{ with .Get "caption" }}
<figcaption>
{{ . }}
</figcaption>
{{ end }}
</figure>

View File

@@ -0,0 +1,10 @@
<video controls
{{ with .Get "poster" }}poster="{{ . }}"{{ end }}
{{ with .Get "width" }}width="{{ . }}"{{ end }}
{{ with .Get "height" }}height="{{ . }}"{{ end }}
>
<source
{{ with .Get "type" }}type="{{ . }}"{{ end }}
src="{{ (.Page.Resources.GetMatch (.Get "src")).RelPermalink }}"
>
</video>

View File

@@ -0,0 +1,9 @@
<iframe
{{ with .Get "width" }}width="{{ . }}"{{ end }}
{{ with .Get "height" }}height="{{ . }}"{{ end }}
src="https://www.youtube-nocookie.com/embed/{{ .Get "id" }}"
title="{{ with .Get "title" }}{{ . }}{{ else }}YouTube video player{{ end }}"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen>
</iframe>