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:
authorSarah German <sgerman@gitlab.com>2022-08-16 22:46:55 +0300
committerSarah German <sgerman@gitlab.com>2022-08-18 01:14:10 +0300
commit04f164d2fcdab8ce97172973f325c0b43ded2391 (patch)
tree8684d88d9b5d1a4b335d7bb2638242313463f60e
parent28975d1f6f620d8381a4bdbb90a501f07d4a4de8 (diff)
Conditional indexing on CIlunr-node-index
-rw-r--r--.gitlab/ci/build-and-deploy.gitlab-ci.yml7
-rw-r--r--lib/helpers/generic.rb7
2 files changed, 13 insertions, 1 deletions
diff --git a/.gitlab/ci/build-and-deploy.gitlab-ci.yml b/.gitlab/ci/build-and-deploy.gitlab-ci.yml
index e1ba016e..8cc8aa13 100644
--- a/.gitlab/ci/build-and-deploy.gitlab-ci.yml
+++ b/.gitlab/ci/build-and-deploy.gitlab-ci.yml
@@ -12,6 +12,8 @@
- bundle exec nanoc compile -VV
# Create _redirects for Pages redirects
- bundle exec rake redirects
+ # Build the Lunr.js search index if needed
+ - if [[ "$ALGOLIA_SEARCH" == "false" ]]; then node scripts/lunr/preindex.js; fi
# Calculate sizes before and after minifying/gzipping the static files (HTML, CSS, JS)
- SIZE_BEFORE=$(du -sh public/ | awk '{print $1}')
# Minify the assets of the resulting site
@@ -21,7 +23,7 @@
- SIZE_AFTER_MINIFY=$(du -sh public/ | awk '{print $1}')
# Use gzip to compress static content for faster web serving
# https://docs.gitlab.com/ee/user/project/pages/introduction.html#serving-compressed-assets
- - find public/ -type f \( -iname "*.html" -o -iname "*.js" -o -iname "*.css" -o -iname "*.svg" \) -exec gzip --keep --best --force --verbose {} \;
+ - find public/ -type f \( -iname "*.html" -o -iname "*.js" -o -iname "*.css" -o -iname "*.svg" -o -iname "*.json" \) -exec gzip --keep --best --force --verbose {} \;
- SIZE_AFTER_GZIP=$(du -sh public/ | awk '{print $1}')
# Print size results
- echo "Minify and compress the static assets (HTML, CSS, JS)"
@@ -40,6 +42,7 @@ compile_prod:
- .rules_prod
- .build_base
variables:
+ ALGOLIA_SEARCH: 'true'
NANOC_ENV: 'production'
#
@@ -49,6 +52,8 @@ compile_dev:
extends:
- .rules_dev
- .build_base
+ variables:
+ ALGOLIA_SEARCH: 'false'
###############################################
diff --git a/lib/helpers/generic.rb b/lib/helpers/generic.rb
index 1f7a091c..5db5f02f 100644
--- a/lib/helpers/generic.rb
+++ b/lib/helpers/generic.rb
@@ -53,5 +53,12 @@ module Nanoc::Helpers
def show_banner?
@items['/_data/banner.yaml'][:show_banner]
end
+
+ #
+ # Check if this environment is set to run Algolia search.
+ #
+ def algolia?
+ ENV['ALGOLIA_SEARCH'] == "true"
+ end
end
end