mirror of https://github.com/theNewDynamic/gohugo-theme-ananke.git

Patrick Kollitsch
2 days ago ae0c6ae00a249f9c3cc819edbfb899fe309d406e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 -}}