{{/* prettier-ignore-start */ -}} {{- /* Renders a callout or badge indicating the version in which a feature was added. To render a callout, include descriptive text between the opening and closing tags. To render a badge,omit the descriptive text and call the shortcode with a self-closing tag. When comparing the current version to the specified version, the "new in" button will be hidden if any of the following conditions is true: - The major version difference exceeds the majorVersionDiffThreshold - The minor version difference exceeds the minorVersionDiffThreshold @param {string} 0 The semantic version string, with or without a leading v. @example {{< new-in 0.100.0 />}} @example {{{< new-in 0.100.0 >}} Some descriptive text here. {{< /new-in >}} */ -}} {{/* prettier-ignore-end */ -}} {{- $majorVersionDiffThreshold := 0 }} {{- $minorVersionDiffThreshold := 30 }} {{- $displayExpirationWarning := true }} {{- with $version := .Get 0 | strings.TrimLeft "vV" }} {{- $majorVersionDiff := sub (index (split hugo.Version ".") 0 | int) (index (split $version ".") 0 | int) }} {{- $minorVersionDiff := sub (index (split hugo.Version ".") 1 | int) (index (split $version ".") 1 | int) }} {{- if or (gt $majorVersionDiff $majorVersionDiffThreshold) (gt $minorVersionDiff $minorVersionDiffThreshold) }} {{- if $displayExpirationWarning }} {{- warnf "This call to the %q shortcode should be removed: %s. The button is now hidden because the specified version (%s) is older than the display threshold." $.Name $.Position $version }} {{- end }} {{- else }} {{- $href := printf "https://github.com/gohugoio/hugo/releases/tag/v%s" $version }} {{- with $.Inner }} {{- $inner := strings.TrimSpace . }} {{- $text := printf "New in [v%s](%s)\n\n%s" $version $href $inner | $.Page.RenderString (dict "display" "block") }} {{ partial "layouts/blocks/alert.html" (dict "color" "green" "icon" "exclamation" "text" $text ) }} {{- else }} New in v{{ $version }} {{- end }} {{- end }} {{- else }} {{- errorf "The %q shortcode requires a single positional parameter indicating version. See %s" .Name .Position }} {{- end }}