Class: Jekyll::LlmsOutput::FullBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-llms-output/full_builder.rb

Overview

Builds the body of /llms-full.txt: a concatenation of every document’s source markdown, separated by a configurable delimiter, each with a small header (title + url) for context.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, options) ⇒ FullBuilder

Returns a new instance of FullBuilder.



11
12
13
14
# File 'lib/jekyll-llms-output/full_builder.rb', line 11

def initialize(site, options)
  @site = site
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/jekyll-llms-output/full_builder.rb', line 9

def options
  @options
end

#siteObject (readonly)

Returns the value of attribute site.



9
10
11
# File 'lib/jekyll-llms-output/full_builder.rb', line 9

def site
  @site
end

Instance Method Details

#buildObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jekyll-llms-output/full_builder.rb', line 16

def build
  chunks = []

  Array(options["collections"]).each do |coll_name|
    collection = site.collections[coll_name.to_s]
    next unless collection
    collection.docs.each { |doc| chunks << render_doc(doc) }
  end

  if options["pages"]
    exts = Array(options["page_extensions"]).map(&:downcase)
    site.pages.each do |page|
      next unless exts.include?(File.extname(page.path).downcase)
      chunks << render_doc(page)
    end
  end

  chunks.compact.join(options["separator"] || "\n\n---\n\n") + "\n"
end