module Jekyll::Algolia::Configurator

def self.api_key

_algolia_api_key file in the Jekyll folder
Will first try to read the ENV variable. Will otherwise try to read the

Public: Return the api key
def self.api_key
  # Alway taking the ENV variable first
  return ENV['ALGOLIA_API_KEY'] if ENV['ALGOLIA_API_KEY']
  # Reading from file on disk otherwise
  source_dir = get('source')
  if source_dir
    api_key_file = File.join(source_dir, '_algolia_api_key')
    if File.exist?(api_key_file) && File.size(api_key_file).positive?
      return File.open(api_key_file).read.strip
    end
  end
  nil
end