diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1acb7308d..76a649621 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -325,6 +325,14 @@ Use the following for project names: /{{< latest "telegraf" >}}/ ``` +### Latest patch version +Use the `{{< latest-patch >}}` shortcode to add the latest patch version of the +current product. Easier to maintain being you update the version number in the `data/products.yml` file instead of updating individual links and code examples. + +```md +{{< latest-patch >}} +``` + ### Tabbed Content Shortcodes are available for creating "tabbed" content (content that is changed by a users' selection). Ther following three must be used: diff --git a/data/products.yml b/data/products.yml index 3b5c0518b..1e1aa39cb 100644 --- a/data/products.yml +++ b/data/products.yml @@ -6,6 +6,8 @@ influxdb: versions: [v1.3, v1.4, v1.5, v1.6, v1.7, v1.8, v2.0] latest: v2.0 latest_override: v2.0 + latest_patches: + "2.0": 6 influxdb_cloud: name: InfluxDB Cloud @@ -43,3 +45,8 @@ enterprise_influxdb: list_order: 3 versions: [v1.5, v1.6, v1.7, v1.8] latest: v1.8 + latest_patches: + "1.5": 4 + "1.6": 6 + "1.7": 10 + "1.8": 5 diff --git a/layouts/shortcodes/latest-patch.html b/layouts/shortcodes/latest-patch.html new file mode 100644 index 000000000..3651bbc57 --- /dev/null +++ b/layouts/shortcodes/latest-patch.html @@ -0,0 +1,12 @@ +{{- $scratch := newScratch -}} +{{- $productPathData := findRE "[^/]+.*?" .Page.RelPermalink -}} +{{- $product := index $productPathData 0 | default "influxdb" -}} +{{- $currentVersion := replaceRE "v" "" (index $productPathData 1) -}} +{{- $latestVersion := replaceRE "v" "" (index (index .Site.Data.products $product) "latest") -}} +{{- $patchVersions := index (index .Site.Data.products $product) "latest_patches" -}} +{{- if eq $currentVersion "cloud" -}} + {{- $scratch.Set "patchVersion" (print $latestVersion "." (index $patchVersions $latestVersion)) -}} +{{- else -}} + {{- $scratch.Set "patchVersion" (print $currentVersion "." (index $patchVersions $currentVersion)) -}} +{{- end -}} +{{- $scratch.Get "patchVersion" -}} \ No newline at end of file