diff options
author | Marcel Amirault <mamirault@gitlab.com> | 2021-04-02 18:40:25 +0300 |
---|---|---|
committer | Marcel Amirault <mamirault@gitlab.com> | 2021-04-02 18:40:25 +0300 |
commit | 8835f2a3e4172ed0c91715483be4881fb7d5f0cb (patch) | |
tree | 27cee3d69d150533bda39d39f1ea653d07feb137 | |
parent | 09bb359becf0c24a5715b9291c9be86d2aa33e22 (diff) | |
parent | ddb4f9ae3fb339d59801835a353b974aadb285e0 (diff) |
Merge branch 'backport-noindex-13-7' into '13.7'13.7
Backport noindex to 13.7
See merge request gitlab-org/gitlab-docs!1654
-rw-r--r-- | layouts/head.html | 2 | ||||
-rw-r--r-- | lib/helpers/generic.rb | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/layouts/head.html b/layouts/head.html index 5bf94d63..c88972d1 100644 --- a/layouts/head.html +++ b/layouts/head.html @@ -10,7 +10,7 @@ <meta name="description" content="Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner."> <% end %> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> -<% if @item[:noindex] %> +<% if @item[:noindex] or !production_and_default_branch? %> <meta name="robots" content="noindex nofollow"> <% end %> <!--https://community.algolia.com/docsearch/required-configuration.html#introduces-global-information-as-meta-tags--> diff --git a/lib/helpers/generic.rb b/lib/helpers/generic.rb index 09c03e80..564118e8 100644 --- a/lib/helpers/generic.rb +++ b/lib/helpers/generic.rb @@ -9,8 +9,33 @@ module Nanoc::Helpers ENV['NANOC_ENV'] == 'production' end + # + # Check if NANOC_ENV is set to production and the branch is the default one. + # For things that should only be built in production of the default branch. + # Sometimes we don't want things to be deployed into the stable branches, + # which they are considered production. + # + def production_and_default_branch? + ENV['NANOC_ENV'] == 'production' && ENV['CI_DEFAULT_BRANCH'] == ENV['CI_COMMIT_REF_NAME'] + end + + # + # Used when bundling gitlab-docs with Omnibus + # def omnibus? ENV['NANOC_ENV'] == 'omnibus' end + + # + # Find the current branch. If CI_COMMIT_BRANCH is not defined, that means + # we're working locally, and Git is used to find the branch. + # + def current_branch + if ENV['CI_COMMIT_REF_NAME'].nil? + `git branch --show-current`.tr("\n", '') + else + ENV['CI_COMMIT_REF_NAME'] + end + end end end |