diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2021-04-20 14:03:09 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2021-04-26 11:56:49 +0300 |
commit | 1c92127f186205d3ce985dd50ed203d20d28aacf (patch) | |
tree | cfce4872e875ae198e701b2cffbe89b66ba3c49b | |
parent | 93396cb5ed66de6f3ada206cfc9243846086343c (diff) |
Add helper that checks the CI_PROJECT_NAME
Check if CI_PROJECT_NAME is 'gitlab-docs', or nil which implies
local development. This can be used to skip portions that we
don't want to render in one of the upstream products.
-rw-r--r-- | content/index.erb | 2 | ||||
-rw-r--r-- | layouts/default.html | 3 | ||||
-rw-r--r-- | lib/helpers/generic.rb | 9 |
3 files changed, 12 insertions, 2 deletions
diff --git a/content/index.erb b/content/index.erb index d889ba39..f1785059 100644 --- a/content/index.erb +++ b/content/index.erb @@ -2,7 +2,7 @@ title: GitLab Documentation --- <!-- Render the front page only if CI_PROJECT_NAME is gitlab-docs or is not set --> -<% if ENV['CI_PROJECT_NAME'] == 'gitlab-docs' or ENV['CI_PROJECT_NAME'].nil? %> +<% if gitlab_docs_or_local? %> <!-- Hero--> <section class="hero text-center pt-5 mt-3"> <%= render '/banner.*' %> diff --git a/layouts/default.html b/layouts/default.html index 28cf7ba5..83556510 100644 --- a/layouts/default.html +++ b/layouts/default.html @@ -14,7 +14,8 @@ <div class="col-0 col-lg-2 pl-0"> <div class="nav-wrapper active"> <aside id="global-nav" class="global-nav"> - <% if ENV['CI_PROJECT_NAME'] == 'gitlab-docs' or ENV['CI_PROJECT_NAME'].nil? %> + <!-- Render the global nav only if CI_PROJECT_NAME is gitlab-docs or is not set --> + <% if gitlab_docs_or_local? %> <%= render '/global_nav.*' %> <% end %> </aside> diff --git a/lib/helpers/generic.rb b/lib/helpers/generic.rb index 564118e8..c9254368 100644 --- a/lib/helpers/generic.rb +++ b/lib/helpers/generic.rb @@ -37,5 +37,14 @@ module Nanoc::Helpers ENV['CI_COMMIT_REF_NAME'] end end + + # + # Check if CI_PROJECT_NAME is 'gitlab-docs', or nil which implies + # local development. This can be used to skip portions that we + # don't want to render in one of the upstream products. + # + def gitlab_docs_or_local? + ENV['CI_PROJECT_NAME'] == 'gitlab-docs' or ENV['CI_PROJECT_NAME'].nil? + end end end |