module Jekyll::Algolia::Hooks
def self.apply_all(records, context)
as they can be mocked in tests.
by users. Using a wrapper around it makes testing their behavior easier
This method is a simple wrapper around methods that can be overwritten
Public: Apply the before_indexing_all hook to all records.
def self.apply_all(records, context) case method(:before_indexing_all).arity when 1 before_indexing_all(records) else before_indexing_all(records, context) end end
def self.apply_each(record, node, context)
record - The hash of the record to be pushed
as they can be mocked in tests.
by users. Using a wrapper around it makes testing their behavior easier
This method is a simple wrapper around methods that can be overwritten
Public: Apply the before_indexing_each hook to the record.
def self.apply_each(record, node, context) case method(:before_indexing_each).arity when 1 before_indexing_each(record) when 2 before_indexing_each(record, node) else before_indexing_each(record, node, context) end end
def self.before_indexing_all(records, _context)
interface than `hook_before_indexing_each` when knowing the full context
Users can modify the full list from here. It might provide an easier
records - The list of all records to be indexed
indexing them
Public: Custom method to be run on the list of all records before
def self.before_indexing_all(records, _context) records end
def self.before_indexing_each(record, _node, _context)
information from the HTML node.
be used to remove keys that should not be indexed, or access more
Users can modify the record (adding/editing/removing keys) here. It can
node - The Nokogiri node of the element
record - The hash of the record to be pushed
Public: Custom method to be run on the record before indexing it
def self.before_indexing_each(record, _node, _context) record end
def self.should_be_excluded?(_filepath)
but a custom hook like this one can allow more fine-grained
not. Basic exclusion can be done through the `files_to_exclude` option,
This hook allow users to define if a specific file should be indexed or
filepath - The path to the file, before transformation
Public: Check if the file should be indexed or not
def self.should_be_excluded?(_filepath) false end