blob: ea98b96693da481d91b6d309bcc9ab0d862d6ace (
plain)
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
26
27
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
module Nanoc::Helpers
module VersionsDropdown
STABLE_VERSIONS_REGEX = %r{^\d{1,2}\.\d{1,2}$}.freeze
#
# Determines whether or not to display the version banner on the frontend.
#
# Note: We only want the banner to display on production.
# Production is the only environment where we serve multiple versions.
#
def show_version_banner?
production? && !latest?
end
#
# Check if the current version is the latest.
#
def latest?
latest_version = @items['/_data/versions.yaml'][:online][0]
ENV['CI_COMMIT_REF_NAME'] == ENV['CI_DEFAULT_BRANCH'] || ENV['CI_COMMIT_REF_NAME'] == latest_version
end
#
# Stable versions regexp
#
# At most two digits for major and minor numbers.
#
def stable_version?(version)
version.match?(STABLE_VERSIONS_REGEX)
end
end
end
|