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
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2018-11-23 10:19:12 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2018-11-23 10:19:12 +0300
commit99165f7643878e00bff4dfd1a650e1102124e380 (patch)
treeeba1a613d4e3623c27d42d673f4d29be05055084 /lib/helpers
parentce4cab084771541fe2e5687017073ed93df9e6c9 (diff)
Active class versions
Diffstat (limited to 'lib/helpers')
-rw-r--r--lib/helpers/versions.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/helpers/versions.rb b/lib/helpers/versions.rb
new file mode 100644
index 00000000..7fede237
--- /dev/null
+++ b/lib/helpers/versions.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Nanoc::Helpers
+ module VersionsDropdown
+
+ #
+ # Set the active class based on CI_COMMIT_REF_NAME and exclude if on
+ # the archives page, otherwise we would end up with two active links.
+ #
+ def active_dropdown(selection)
+ if archives?
+ active_class if selection == 'archives'
+ else
+ active_class if selection == ENV['CI_COMMIT_REF_NAME']
+ end
+ end
+
+ #
+ # Check if we are on the /archives page
+ #
+ def archives?
+ @item.identifier.to_s.split('/')[1] == 'archives'
+ end
+
+ #
+ # Define the active CSS class
+ #
+ def active_class
+ %( class="active")
+ end
+
+ end
+end