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

diff --git a/themes/danix-xyz-hacker/shortcodes/gallery.html b/themes/danix-xyz-hacker/shortcodes/gallery.html
new file mode 100644 (file)
index 0000000..b66c327
--- /dev/null
@@ -0,0 +1,12 @@
+{{- $cols := .Get "cols" | default "2" -}}
+
+<div class="my-8 grid gap-4" style="grid-template-columns: repeat({{ $cols }}, 1fr)">
+  {{- range $line := strings.Split .Inner "\n" -}}
+    {{- if strings.Contains $line "![" -}}
+      {{- $image := strings.TrimSpace $line -}}
+      {{- if $image -}}
+        {{ $image | markdownify | safeHTML }}
+      {{- end -}}
+    {{- end -}}
+  {{- end -}}
+</div>