diff options
| author | Danilo M. <danix@danix.xyz> | 2026-04-15 15:52:14 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-04-15 15:52:14 +0200 |
| commit | 0848ab287f117f740977c1309365f6700e63aabc (patch) | |
| tree | c08a7e19a60e9407768ac913e7d5405b9a127518 /themes/danix-xyz-hacker/shortcodes/image.html | |
| parent | 798970f43e522e4b54207a79bf52dee8710d84dc (diff) | |
| download | danixxyz-0848ab287f117f740977c1309365f6700e63aabc.tar.gz danixxyz-0848ab287f117f740977c1309365f6700e63aabc.zip | |
feat: create image shortcode with lazy-loading and captions
Diffstat (limited to 'themes/danix-xyz-hacker/shortcodes/image.html')
| -rw-r--r-- | themes/danix-xyz-hacker/shortcodes/image.html | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/themes/danix-xyz-hacker/shortcodes/image.html b/themes/danix-xyz-hacker/shortcodes/image.html new file mode 100644 index 0000000..07a698d --- /dev/null +++ b/themes/danix-xyz-hacker/shortcodes/image.html @@ -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 -}} |
