Class: Jekyll::ClientSearch::DocumentBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/client_search/document_builder.rb

Overview

Normalizes Jekyll documents and pages into the flat hash shape that the search index JSON emits.

Instance Method Summary collapse

Instance Method Details

#from_document(document, source: nil, passthrough_fields: []) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jekyll/client_search/document_builder.rb', line 8

def from_document(document, source: nil, passthrough_fields: [])
  url = document.url.to_s
  return if url.empty?

  data = document.data
  core_fields(document, data, url)
    .compact
    .merge("source" => source)
    .merge(passthrough(data, passthrough_fields))
    .compact
end