|
| 1 | +{% set currentVersion = "v" ~ bolt.data.fullManifest.version %} |
| 2 | +{% set latestVersion = bolt.data.boltReleases.options[0] %} |
| 3 | +{% set isNotStable = |
| 4 | + "alpha" in currentVersion or |
| 5 | + "beta" in currentVersion or |
| 6 | + "rc" in currentVersion |
| 7 | + ? true : false |
| 8 | +%} |
| 9 | + |
| 10 | +{% set latestStableVersion = "" %} |
| 11 | +{% set previousStableVersion = "" %} |
| 12 | + |
| 13 | +{# is this (the local version of Bolt) also the latest version? #} |
| 14 | +{% if latestVersion.label == currentVersion %} |
| 15 | + {% set isLocalVersionTheLatest = true %} |
| 16 | +{% else %} |
| 17 | + {% set isLocalVersionTheLatest = false %} |
| 18 | +{% endif %} |
| 19 | + |
| 20 | +{% for option in bolt.data.boltReleases.options %} |
| 21 | + {% set v = option.label %} |
| 22 | + {% set isStable = "alpha" not in v and "beta" not in v and "rc" not in v %} |
| 23 | + |
| 24 | + {% if v != currentVersion and isStable and previousStableVersion == "" %} |
| 25 | + {% set previousStableVersion = option %} |
| 26 | + {% endif %} |
| 27 | + |
| 28 | + {% if isStable and latestStableVersion == "" %} |
| 29 | + {% set latestStableVersion = option %} |
| 30 | + {% endif %} |
| 31 | +{% endfor %} |
| 32 | + |
| 33 | +{% if isLocalVersionTheLatest %} |
| 34 | + {% set suggestedText = "alpha" not in previousStableVersion.value and "beta" not in previousStableVersion.value and "rc" not in previousStableVersion.value and isNotStable ? 'the latest stable' : 'the previous' %} |
| 35 | + {% set suggestedLink = previousStableVersion %} |
| 36 | +{% elseif currentVersion != latestStableVersion.label %} |
| 37 | + {% set suggestedText = "the latest stable" %} |
| 38 | + {% set suggestedLink = latestStableVersion %} |
| 39 | +{% else %} |
| 40 | + {% set suggestedText = "alpha" not in latestVersion.value and "beta" not in latestVersion.value and "rc" not in latestVersion.value ? 'the latest' : 'the upcoming' %} |
| 41 | + {% set suggestedLink = latestVersion %} |
| 42 | +{% endif %} |
| 43 | + |
| 44 | +{% if isNotStable and latestVersion.label == currentVersion %} |
| 45 | + {% set currentVersionText = "an upcoming " %} |
| 46 | +{% elseif latestStableVersion.label == currentVersion %} |
| 47 | + {% set currentVersionText = "the latest stable " %} |
| 48 | +{% elseif latestVersion.label == currentVersion %} |
| 49 | + {% set currentVersionText = "the latest " %} |
| 50 | +{% else %} |
| 51 | + {% set currentVersionText = "a previous " %} |
| 52 | +{% endif %} |
| 53 | + |
| 54 | +{% set suggestedRenderedLink = include("@bolt-components-link/link.twig", { |
| 55 | + text: suggestedLink.label, |
| 56 | + url: suggestedLink.value, |
| 57 | +}) %} |
| 58 | + |
| 59 | +{% set text %} |
| 60 | + {% spaceless %} |
| 61 | + These are the docs for {{ currentVersionText }} release of the Bolt Design System. Looking for {{ suggestedText }} release, {{ suggestedRenderedLink }}? |
| 62 | + {% endspaceless %} |
| 63 | +{% endset %} |
| 64 | + |
| 65 | +{% set bannerText = include("@bolt-components-headline/text.twig", { |
| 66 | + size: "small", |
| 67 | + text: text |
| 68 | +}) %} |
| 69 | + |
| 70 | +{% include "@bolt-site/banner.twig" with { |
| 71 | + text: bannerText |
| 72 | +} only %} |
0 commit comments