From ae0c6ae00a249f9c3cc819edbfb899fe309d406e Mon Sep 17 00:00:00 2001
From: Patrick Kollitsch <davidsneighbourdev+gh@gmail.com>
Date: Sun, 07 Jun 2026 00:55:34 +0000
Subject: [PATCH] feat: add since shortcode for release badges

---
 config/_default/params.toml    |    5 +++++
 i18n/en.toml                   |    3 +++
 layouts/_shortcodes/since.html |   25 +++++++++++++++++++++++++
 3 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/config/_default/params.toml b/config/_default/params.toml
index 612f05f..f4e7589 100644
--- a/config/_default/params.toml
+++ b/config/_default/params.toml
@@ -4,6 +4,11 @@
 [ananke.home]
 content_alignment = "center" # options: left, center, right
 
+[ananke.shortcodes.since]
+# printf format string for the `since` shortcode's release link.
+# %s is replaced with the version. Point this at your own project's releases.
+url = "https://github.com/gohugo-ananke/ananke/releases/tag/v%s"
+
 [ananke.social]
 icon_path = "ananke/socials/%s.svg"
 
diff --git a/i18n/en.toml b/i18n/en.toml
index 4e5638d..0f4e0e6 100644
--- a/i18n/en.toml
+++ b/i18n/en.toml
@@ -34,6 +34,9 @@
 [send]
 other = "Send"
 
+[since]
+other = "since"
+
 [taxonomyPageList]
 other = "Below you will find pages that utilize the taxonomy term “{{ .Title }}”"
 
diff --git a/layouts/_shortcodes/since.html b/layouts/_shortcodes/since.html
new file mode 100644
index 0000000..35945c9
--- /dev/null
+++ b/layouts/_shortcodes/since.html
@@ -0,0 +1,25 @@
+{{- /*
+  since shortcode
+
+  Renders a small badge linking to the release where a feature was introduced.
+
+  The version is taken from, in order of precedence:
+    - the first positional argument:  since "2.17.0"
+    - the named "version" argument:   since version="2.17.0"
+    - the page's "since" front matter: since = "2.17.0"
+
+  The link target is built from the printf format string in
+  params.ananke.shortcodes.since.url, which receives the version as its only
+  argument (default: the Ananke releases page).
+*/ -}}
+{{- $version := or (.Get 0) (.Get "version") .Page.Params.since -}}
+{{- with $version -}}
+  {{- $urlFormat := site.Params.ananke.shortcodes.since.url | default "https://github.com/gohugo-ananke/ananke/releases/tag/v%s" -}}
+  {{- $url := printf $urlFormat . -}}
+  <a class="f6 link dim br2 ba bw1 ph3 pv2 mb2 dib navy"
+    href="{{ $url }}" target="_blank" rel="noopener">
+    {{ T "since" }} {{ . }}
+  </a>
+{{- else -}}
+  {{- warnf "[ananke] the 'since' shortcode in %q needs a version argument or a 'since' front matter value" .Page.File.Path -}}
+{{- end -}}

--
Gitblit v1.10.0