]> danix's work - danix.xyz-2.git/commitdiff
feat: create image shortcode with lazy-loading and captions
authorDanilo M. <redacted>
Wed, 15 Apr 2026 13:52:14 +0000 (15:52 +0200)
committerDanilo M. <redacted>
Wed, 15 Apr 2026 13:52:14 +0000 (15:52 +0200)
themes/danix-xyz-hacker/shortcodes/image.html [new file with mode: 0644]

diff --git a/themes/danix-xyz-hacker/shortcodes/image.html b/themes/danix-xyz-hacker/shortcodes/image.html
new file mode 100644 (file)
index 0000000..07a698d
--- /dev/null
@@ -0,0 +1,22 @@
+{{- $src := .Get "src" -}}
+{{- $alt := .Get "alt" | default "Image" -}}
+{{- $caption := .Get "caption" -}}
+{{- $class := .Get "class" | default "rounded-lg border border-border/30" -}}
+
+{{- if $src -}}
+  <figure class="my-8">
+    <img
+      src="{{ $src }}"
+      alt="{{ $alt }}"
+      class="{{ $class }} w-full h-auto"
+      loading="lazy"
+    />
+    {{- if $caption -}}
+      <figcaption class="mt-3 text-center text-sm text-text-dim italic">
+        {{ $caption }}
+      </figcaption>
+    {{- end -}}
+  </figure>
+{{- else -}}
+  {{- errorf "image shortcode: 'src' parameter is required" -}}
+{{- end -}}