From fb71d100fe069244d1fcbe3f48c976ab7a0558e2 Mon Sep 17 00:00:00 2001
From: Patrick Kollitsch <83281+davidsneighbour@users.noreply.github.com>
Date: Sun, 07 Jun 2026 03:47:20 +0000
Subject: [PATCH] feat: add since shortcode for release badges (#1018)

---
 i18n/en.toml                   |    3 +++
 layouts/_shortcodes/since.html |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 0 deletions(-)

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..d0c902b
--- /dev/null
+++ b/layouts/_shortcodes/since.html
@@ -0,0 +1,52 @@
+{{- /*
+  since shortcode
+
+  Renders a small badge marking the release a feature was introduced in.
+
+  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"
+
+  Configuration (all optional, not set by default):
+    - params.ananke.shortcodes.since.repo_url
+        A printf format string receiving the version (e.g. ".../tag/v%s").
+        When unset the badge renders as plain text with no link.
+    - params.ananke.shortcodes.since.target
+        Link target. Defaults to "_blank". Set to a custom value (e.g. "_top")
+        or to false to open in the same window.
+*/ -}}
+{{- $version := "" -}}
+{{- with .Page.Params.since }}{{ $version = . }}{{ end -}}
+{{- if .IsNamedParams -}}
+  {{- with .Get "version" }}{{ $version = . }}{{ end -}}
+{{- else -}}
+  {{- with .Get 0 }}{{ $version = . }}{{ end -}}
+{{- end -}}
+{{- with $version -}}
+  {{- $repoURL := "" -}}
+  {{- $target := "_blank" -}}
+  {{- with site.Params.ananke -}}
+    {{- with .shortcodes -}}
+      {{- with .since -}}
+        {{- with .repo_url }}{{ $repoURL = . }}{{ end -}}
+        {{- if isset . "target" }}{{ $target = .target }}{{ end -}}
+      {{- end -}}
+    {{- end -}}
+  {{- end -}}
+  {{- $label := printf "%s %s" (T "since") . -}}
+  {{- if $repoURL -}}
+    {{- $url := printf $repoURL . -}}
+    {{- $rel := "" -}}
+    {{- if and $target (ne $target "_self") }}{{ $rel = "noopener" }}{{ end -}}
+    <a class="f6 link dim br2 ba bw1 ph3 pv2 mb2 dib navy" href="{{ $url }}"
+      {{- with $target }} target="{{ . }}"{{ end -}}
+      {{- with $rel }} rel="{{ . }}"{{ end }}>
+      {{ $label }}
+    </a>
+  {{- else -}}
+    <span class="f6 br2 ba bw1 ph3 pv2 mb2 dib navy">{{ $label }}</span>
+  {{- end -}}
+{{- 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