diff options
-rw-r--r-- | .gitlab/ci/build-and-deploy.gitlab-ci.yml | 7 | ||||
-rw-r--r-- | lib/helpers/generic.rb | 7 |
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 |