From 1843748eb6326bfc891c07e8ff7781974e4bede4 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 11 Jun 2024 15:49:21 +0200
Subject: [PATCH] [web] Added optional paramater to dataFile-shortcode to get
 version comp

---
 web/layouts/shortcodes/dataFile.html | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/web/layouts/shortcodes/dataFile.html b/web/layouts/shortcodes/dataFile.html
index d47c61c71a2..23e7a3a4596 100644
--- a/web/layouts/shortcodes/dataFile.html
+++ b/web/layouts/shortcodes/dataFile.html
@@ -2,7 +2,14 @@
   {{- $map := split . "." }}
   {{- $url := index $.Site.Data $map -}}
   {{- if $url -}}
-{{- $url -}}
+    {# Second parameter allows to get a version component, starting with index 1 #}
+    {{- with $.Get 1 -}}
+      {# Start with index 1, subtract 1 to get zero-based index #}
+      {{- $index := math.Sub . 1 -}}
+      {{- $version_comps := split $url "." -}}
+      {{- $url = index $version_comps $index -}}
+    {{- end -}}
+    {{- $url -}}
   {{- else -}}
 {{- errorf "No data for key %s" . -}}
   {{- end -}}
-- 
GitLab