class Jekyll::Algolia::Site

def write

def write
  if Configurator.dry_run?
    Logger.log('W:==== THIS IS A DRY RUN ====')
    Logger.log('W:  - No records will be pushed to your index')
    Logger.log('W:  - No settings will be updated on your index')
  end
  records = []
  files = []
  each_site_file do |file|
    # Skip files that should not be indexed
    is_indexable = FileBrowser.indexable?(file)
    unless is_indexable
      Logger.verbose("W:Skipping #{file.path}")
      next
    end
    path = FileBrowser.path_from_root(file)
    Logger.verbose("I:Extracting records from #{path}")
    file_records = Extractor.run(file)
    files << file
    records += file_records
  end
  # Applying the user hook on the whole list of records
  records = Hooks.apply_all(records)
  # Adding a unique objectID to each record
  records.map! do |record|
    Extractor.add_unique_object_id(record)
  end
  Logger.verbose("I:Found #{files.length} files")
  Indexer.run(records)
end