Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJacques Erasmus <jerasmus@gitlab.com>2019-11-15 13:33:33 +0300
committerJacques Erasmus <jerasmus@gitlab.com>2019-11-15 13:33:33 +0300
commit1fda2494ea177d0ee690e7726db1e2a9e02bd7c7 (patch)
treebea8c3dbb631c6df0a299d2e54a06a5e24700402 /lib
parent985f3927201f0d5444889bb2852c7bdfc5cd50ec (diff)
Display version banner for outdated docs
Added the ability to display a version banner for outdated docs
Diffstat (limited to 'lib')
-rw-r--r--lib/helpers/versions.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/helpers/versions.rb b/lib/helpers/versions.rb
index 52764735..5f5c3287 100644
--- a/lib/helpers/versions.rb
+++ b/lib/helpers/versions.rb
@@ -18,6 +18,24 @@ module Nanoc::Helpers
end
#
+ # 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?
+ ENV['NANOC_ENV'] == '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'] == 'master' || ENV['CI_COMMIT_REF_NAME'] == latest_version
+ end
+
+ #
# Check if we are on the /archives page
#
def archives?