summaryrefslogtreecommitdiffstats
path: root/themes/danix-xyz-hacker/layouts/shortcodes/video.html
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-18 18:19:47 +0200
committerDanilo M. <danix@danix.xyz>2026-04-18 18:19:47 +0200
commit46779476a570346661a2741607265caed42829b2 (patch)
tree40ceae59ea6733fbd4dcce41d9ff6e5b24fc3d4e /themes/danix-xyz-hacker/layouts/shortcodes/video.html
parentc1407fa9fb558e42588aa194a53e78a087f045f0 (diff)
downloaddanixxyz-46779476a570346661a2741607265caed42829b2.tar.gz
danixxyz-46779476a570346661a2741607265caed42829b2.zip
consolidated duplicated shortcodes. Initial fix of the content files. Manual review needed
Diffstat (limited to 'themes/danix-xyz-hacker/layouts/shortcodes/video.html')
-rw-r--r--themes/danix-xyz-hacker/layouts/shortcodes/video.html76
1 files changed, 35 insertions, 41 deletions
diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/video.html b/themes/danix-xyz-hacker/layouts/shortcodes/video.html
index a07500a..1e2645d 100644
--- a/themes/danix-xyz-hacker/layouts/shortcodes/video.html
+++ b/themes/danix-xyz-hacker/layouts/shortcodes/video.html
@@ -1,43 +1,37 @@
-{{/*
- * The video shortcode:
- * All arguments are optional, except for src which is where you define your video file
- * This shortcode supports only webm video files.
- * Args:
- * class: [string] The class(es) to give to the video block.
- * width: [int] The width of the video
- * height: [int] The height of the video
- * autoplay: [bool] true or false for autoplay - defaults to false
- * loop: [bool] true or false for loop - defaults to false
- * mute: [bool] true or false for mute - defaults to false
- *
- * Usage:
- * {{< video src="my-awesome-video.mp4" width=600 height=600 autoplay=true loop=true mute=true class="some class" >}}
- *
- * Output:
- * <video class="some class" controls preload="auto" width="600" height="600" autoplay loop muted>
- <source src="my-awesome-video.mp4" type="video/webm">
- * </video>
- *
- */}}
+{{- $src := .Get "src" -}}
+{{- $id := .Get "id" -}}
+{{- $title := .Get "title" | default "Video" -}}
+{{- $class := .Get "class" | default "" -}}
-{{ $srcParam := .Get "src" }}
-{{ $ext := $srcParam | path.Ext }}
-{{ $filetype := slicestr $ext 1 }}
-
-{{ $videoURL := $srcParam }}
-{{ $resource := .Page.Resources.GetMatch $srcParam }}
-{{ if $resource }}
- {{ $videoURL = $resource.RelPermalink }}
-{{ end }}
-
-<video{{ with .Get "class" }} class="{{ . }}"{{ end }}
- controls
- preload="auto"
- {{ with .Get "width" }}width="{{.}}"{{ end }}
- {{ with .Get "height" }}height="{{.}}"{{ end }}
- {{ if eq (.Get "autoplay") "true" }}autoplay {{ end }}
- {{ if eq (.Get "loop") "true" }}loop {{ end }}
- {{ if eq (.Get "muted") "true" }}muted {{ end }}
- playsinline >
+{{- if $id -}}
+ <div class="my-6{{- with $class }} {{ . }}{{- end -}}">
+ <iframe
+ class="w-full aspect-video"
+ src="https://www.youtube.com/embed/{{ $id }}"
+ title="{{ $title }}"
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
+ allowfullscreen
+ ></iframe>
+ </div>
+{{- else if $src -}}
+ {{- $ext := $src | path.Ext -}}
+ {{- $filetype := slicestr $ext 1 -}}
+ {{- $videoURL := $src -}}
+ {{- $resource := .Page.Resources.GetMatch $src -}}
+ {{- if $resource -}}{{- $videoURL = $resource.RelPermalink -}}{{- end -}}
+ <video
+ {{- with $class }} class="{{ . }}"{{ end }}
+ controls
+ preload="auto"
+ playsinline
+ {{- with .Get "width" }} width="{{ . }}"{{ end }}
+ {{- with .Get "height" }} height="{{ . }}"{{ end }}
+ {{- if eq (.Get "autoplay") "true" }} autoplay{{ end }}
+ {{- if eq (.Get "loop") "true" }} loop{{ end }}
+ {{- if eq (.Get "muted") "true" }} muted{{ end }}
+ >
<source src="{{ $videoURL }}" type="video/{{ $filetype }}">
-</video>
+ </video>
+{{- else -}}
+ {{- errorf "video shortcode: either 'src' or 'id' parameter is required" -}}
+{{- end -}}