diff --git a/hugo.yaml b/hugo.yaml index 6c02ea3b9c..5c74d194c8 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -103,8 +103,14 @@ params: example_alpine_version: "3.19" example_node_version: "20" - min_api_threshold: 1.41 - + min_version_thresholds: + buildx: "0.10.0" + buildkit: "0.11.0" + engine: "24.0.0" + api: "1.41" + desktop: "4.20.0" + compose: "2.20.0" + scout: "1.0.0" menus: main: diff --git a/i18n/en.yaml b/i18n/en.yaml index ff9b611444..2b74f96d13 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -25,3 +25,20 @@ apiPropReq: other: Required apiPropDesc: other: Description + +## component names + +buildx: + other: Buildx +buildkit: + other: BuildKit +engine: + other: Docker Engine +api: + other: Engine API +desktop: + other: Docker Desktop +compose: + other: Docker Compose +scout: + other: Docker Scout diff --git a/layouts/shortcodes/introduced.html b/layouts/shortcodes/introduced.html new file mode 100644 index 0000000000..60b62dcfe4 --- /dev/null +++ b/layouts/shortcodes/introduced.html @@ -0,0 +1,59 @@ +{{- /* +Renders a version callout for when a feature was introduced in a component. + +Accepts positional parameters. +Depends on site.Params.min_version_thresholds and i18n strings for component IDs + +@param {string} component The ID of the component as defined in site config. +@param {string} version The version of the component in which the thing was introduced. +@param {string} [link] A relevant link to e.g. release note. + +@returns {template.HTML} + +@examples + + {{< introduced buildx 0.12.0 "../release-notes.md#0120" >}} + + {{< introduced desktop "4.28" "https://example.com/" >}} + +*/ -}} + +{{- $component := .Get 0 }} +{{- $v := .Get 1 }} +{{- $link := .Get 2 }} +{{- $pos := .Position }} +{{- with (index site.Params.min_version_thresholds $component) }} + {{- /* + Hacky semver comparison. + + - Split the input version and threshold version strings + - Range over the input version []string + - Cast to ints and compare input with same index threshold []string + - Set threshold false if input is lower than config, and break + */ -}} + {{ $vslice := strings.Split $v "." }} + {{ $tslice := strings.Split . "." }} + {{ $versionAboveThreshold := true }} + {{ range $i, $e := $vslice }} + {{ if compare.Lt (cast.ToInt $e) (cast.ToInt (index $tslice $i)) }} + {{ $versionAboveThreshold = false }} + {{ break }} + {{ end }} + {{ end }} + {{- if $versionAboveThreshold }} +
+ {{ partial "icon.html" "chevron_right" }} + Introduced in {{ T $component }} version + {{- if $link }} + {{ page.RenderString (fmt.Printf `[%s](%s)` $v $link) }} + {{- else }} + {{ $v }} + {{- end }} + +
+ {{- else }} + {{ warnf "[introduced] version below threshold: %s %s %v" $component $v $pos }} + {{- end }} +{{- else }} + {{ errorf "[introduced] invalid component: %s %v" $component $pos }} +{{- end }}