summaryrefslogtreecommitdiffstats
path: root/layouts/shortcodes/image.html
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-04-22 12:42:56 +0200
committerDanilo M. <danix@danix.xyz>2026-04-22 12:42:56 +0200
commit631547a75142326a7c71bdf123e1475217a5ad73 (patch)
treef3cfef6b3c5b42bf626fc823ddcf63b8dcf4cdbb /layouts/shortcodes/image.html
parent77ccbe72fad5a4870185fff374f75471c16a9043 (diff)
downloaddanixxyz-theme-631547a75142326a7c71bdf123e1475217a5ad73.tar.gz
danixxyz-theme-631547a75142326a7c71bdf123e1475217a5ad73.zip
chore: replace with extracted danix.xyz-hacker theme (danix2-hugo-theme)
Diffstat (limited to 'layouts/shortcodes/image.html')
-rw-r--r--layouts/shortcodes/image.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/layouts/shortcodes/image.html b/layouts/shortcodes/image.html
new file mode 100644
index 0000000..84dec3f
--- /dev/null
+++ b/layouts/shortcodes/image.html
@@ -0,0 +1,23 @@
+{{- $src := .Get "src" -}}
+{{- $alt := .Get "alt" | default "Image" -}}
+{{- $caption := .Get "caption" -}}
+{{- $class := .Get "class" | default "w-full h-auto rounded-lg border border-border" -}}
+{{- $link := .Get "link" -}}
+{{- $figureClass := .Get "figure-class" -}}
+
+{{- if or $src .Inner -}}
+ <figure class="my-8{{- with $figureClass }} {{ . }}{{- end -}}">
+ {{- if .Inner -}}
+ {{- .Inner -}}
+ {{- else -}}
+ {{- if $link -}}<a href="{{ $link }}">{{- end -}}
+ <img src="{{ $src }}" alt="{{ $alt }}" class="{{ $class }}" loading="lazy" />
+ {{- if $link -}}</a>{{- end -}}
+ {{- end -}}
+ {{- if $caption -}}
+ <figcaption class="mt-3 text-center text-sm text-text-dim italic">{{ $caption }}</figcaption>
+ {{- end -}}
+ </figure>
+{{- else -}}
+ {{- errorf "image shortcode: 'src' parameter or inner content is required" -}}
+{{- end -}}